Rar4
application/vnd.rar
Magic Bytes
Offset: 0
52 61 72 21 1A 07 01 00
The RAR4 format is a proprietary archive file format developed by Eugene Roshal and maintained by win.rar GmbH. It is primarily utilized for data compression, error recovery, and file spanning across multiple storage volumes. While superseded by the newer RAR5 specification, this legacy format remains widely supported, though users should exercise caution with archives from untrusted sources as they can contain malicious scripts or hidden executable files.
Validation Code
How to validate .rar files in Python
Python
def is_rar(file_path: str) -> bool:
"""Check if file is a valid RAR by magic bytes."""
signature = bytes([0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x01, 0x00])
with open(file_path, "rb") as f:
return f.read(8) == signature
How to validate .rar files in Node.js
Node.js
function isRAR(buffer: Buffer): boolean {
const signature = Buffer.from([0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x01, 0x00]);
return buffer.subarray(0, 8).equals(signature);
}
Go
func IsRAR(data []byte) bool {
signature := []byte{0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x01, 0x00}
if len(data) < 8 {
return false
}
return bytes.Equal(data[:8], signature)
}
API Endpoint
GET
/api/v1/rar
curl https://filesignature.org/api/v1/rar