mcrypt v2
application/x-netcdf
Magic Bytes
Offset: 0
43 44 46 01
Network Common Data Form (NetCDF) is a self-describing, machine-independent file format for array-oriented scientific data, managed by the Unidata program at the University Corporation for Atmospheric Research. It is primarily utilized in the atmospheric, oceanographic, and climate research communities to store and share multidimensional variables such as temperature, humidity, and pressure. This specific version represents the classic binary format, which remains widely supported for legacy data exchange despite the introduction of more advanced HDF5-based versions.
Validation Code
How to validate .nc files in Python
Python
def is_nc(file_path: str) -> bool:
"""Check if file is a valid NC by magic bytes."""
signature = bytes([0x43, 0x44, 0x46, 0x01])
with open(file_path, "rb") as f:
return f.read(4) == signature
How to validate .nc files in Node.js
Node.js
function isNC(buffer: Buffer): boolean {
const signature = Buffer.from([0x43, 0x44, 0x46, 0x01]);
return buffer.subarray(0, 4).equals(signature);
}
Go
func IsNC(data []byte) bool {
signature := []byte{0x43, 0x44, 0x46, 0x01}
if len(data) < 4 {
return false
}
return bytes.Equal(data[:4], signature)
}
API Endpoint
GET
/api/v1/nc
curl https://filesignature.org/api/v1/nc