Tape Archive file
application/x-tar
Magic Bytes
Offset: 257
75 73 74 61 72 00
Tape Archive (TAR) is a file format originally developed for Unix systems to facilitate sequential data storage on physical magnetic tapes. It is primarily utilized for aggregating multiple files into a single uncompressed archive to simplify distribution, backup operations, and file system migrations. Although considered a legacy standard, it remains prevalent in modern Unix-like environments, often combined with compression utilities like Gzip to create compressed archives for software distribution.
Validation Code
How to validate .tar files in Python
Python
def is_tar(file_path: str) -> bool:
"""
Check if file is a valid TAR by magic bytes.
Signature offset: 257 bytes
"""
signature = bytes([0x75, 0x73, 0x74, 0x61, 0x72, 0x00])
with open(file_path, "rb") as f:
f.seek(257)
return f.read(6) == signature
How to validate .tar files in Node.js
Node.js
function isTAR(buffer: Buffer): boolean {
// Signature offset: 257 bytes
const signature = Buffer.from([0x75, 0x73, 0x74, 0x61, 0x72, 0x00]);
if (buffer.length < 263) return false;
return buffer.subarray(257, 263).equals(signature);
}
Go
func IsTAR(data []byte) bool {
// Signature offset: 257 bytes
signature := []byte{0x75, 0x73, 0x74, 0x61, 0x72, 0x00}
if len(data) < 263 {
return false
}
return bytes.Equal(data[257:263], signature)
}
API Endpoint
GET
/api/v1/tar
curl https://filesignature.org/api/v1/tar