7Z
application/x-7z-compressed
Magic Bytes
Offset: 0
37 7A
7z is a compressed archive file format featuring an open architecture, developed by Igor Pavlov and maintained through the 7-Zip project. It is primarily used for consolidating multiple files into a single compressed container for efficient storage, backup, and software distribution. The format supports AES-256 encryption and very large file sizes; while the container structure is secure, users should exercise caution when extracting files from untrusted sources to prevent potential malware execution.
Validation Code
How to validate .7z files in Python
Python
def is_7z(file_path: str) -> bool:
"""Check if file is a valid 7Z by magic bytes."""
signature = bytes([0x37, 0x7A])
with open(file_path, "rb") as f:
return f.read(2) == signature
How to validate .7z files in Node.js
Node.js
function is7Z(buffer: Buffer): boolean {
const signature = Buffer.from([0x37, 0x7A]);
return buffer.subarray(0, 2).equals(signature);
}
Go
func Is7Z(data []byte) bool {
signature := []byte{0x37, 0x7A}
if len(data) < 2 {
return false
}
return bytes.Equal(data[:2], signature)
}
API Endpoint
GET
/api/v1/7z
curl https://filesignature.org/api/v1/7z