CBOR
application/cbor
Magic Bytes
Offset: 0
D9 D9 F7
Concise Binary Object Representation (CBOR) is a standardized data serialization format defined by the Internet Engineering Task Force (IETF) in RFC 8949. It is primarily utilized in the Internet of Things ecosystem and the Constrained Application Protocol to facilitate efficient communication between low-power devices. Designed as a binary alternative to JSON, the format prioritizes code size and message compactness while maintaining a secure structure for data exchange across restricted networks.
Validation Code
How to validate .cbor files in Python
Python
def is_cbor(file_path: str) -> bool:
"""Check if file is a valid CBOR by magic bytes."""
signature = bytes([0xD9, 0xD9, 0xF7])
with open(file_path, "rb") as f:
return f.read(3) == signature
How to validate .cbor files in Node.js
Node.js
function isCBOR(buffer: Buffer): boolean {
const signature = Buffer.from([0xD9, 0xD9, 0xF7]);
return buffer.subarray(0, 3).equals(signature);
}
Go
func IsCBOR(data []byte) bool {
signature := []byte{0xD9, 0xD9, 0xF7}
if len(data) < 3 {
return false
}
return bytes.Equal(data[:3], signature)
}
API Endpoint
GET
/api/v1/cbor
curl https://filesignature.org/api/v1/cbor