Macintosh BinHex 4 Compressed Archive
application/mac-binhex40
Magic Bytes
Offset: 11
6D 75 73 74 20 62 65 20 63 6F 6E 76 65 72 74 65 64 20 77 69 74 68 20 42 69 6E 48 65 78
Macintosh BinHex 4 is a legacy binary-to-text encoding format utilized primarily on classic Mac OS systems. It was designed to preserve Mac-specific file metadata, specifically resource forks, during transmission across non-binary channels like early email and Usenet. While considered obsolete in modern computing environments, these ASCII-encoded archives are still recognized and decoded by specialized archival tools and decompression software.
Validation Code
How to validate .hqx files in Python
Python
def is_hqx(file_path: str) -> bool:
"""
Check if file is a valid HQX by magic bytes.
Signature offset: 11 bytes
"""
signature = bytes([0x6D, 0x75, 0x73, 0x74, 0x20, 0x62, 0x65, 0x20, 0x63, 0x6F, 0x6E, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x42, 0x69, 0x6E, 0x48, 0x65, 0x78])
with open(file_path, "rb") as f:
f.seek(11)
return f.read(29) == signature
How to validate .hqx files in Node.js
Node.js
function isHQX(buffer: Buffer): boolean {
// Signature offset: 11 bytes
const signature = Buffer.from([0x6D, 0x75, 0x73, 0x74, 0x20, 0x62, 0x65, 0x20, 0x63, 0x6F, 0x6E, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x42, 0x69, 0x6E, 0x48, 0x65, 0x78]);
if (buffer.length < 40) return false;
return buffer.subarray(11, 40).equals(signature);
}
Go
func IsHQX(data []byte) bool {
// Signature offset: 11 bytes
signature := []byte{0x6D, 0x75, 0x73, 0x74, 0x20, 0x62, 0x65, 0x20, 0x63, 0x6F, 0x6E, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x42, 0x69, 0x6E, 0x48, 0x65, 0x78}
if len(data) < 40 {
return false
}
return bytes.Equal(data[11:40], signature)
}
API Endpoint
GET
/api/v1/hqx
curl https://filesignature.org/api/v1/hqx