H

text/x-chdr

Safe

Magic Bytes

Offset: 0
23 69 66 6E 64 65 66 20

The C/C++ Header file is a standard source code format originally developed at Bell Labs and maintained by ISO committees for the C and C++ programming languages. Developers utilize these files to define function prototypes, macros, and type definitions intended for sharing across multiple source code modules during compilation. While the file itself consists of safe plain text, unauthorized modifications to these definitions can introduce critical vulnerabilities into the final compiled executable.

Extension

.h

MIME Type

text/x-chdr

Byte Offset

0

Risk Level

Safe

Validation Code

How to validate .h files in Python

Python
def is_h(file_path: str) -> bool:
    """Check if file is a valid H by magic bytes."""
    signature = bytes([0x23, 0x69, 0x66, 0x6E, 0x64, 0x65, 0x66, 0x20])
    with open(file_path, "rb") as f:
        return f.read(8) == signature

How to validate .h files in Node.js

Node.js
function isH(buffer: Buffer): boolean {
  const signature = Buffer.from([0x23, 0x69, 0x66, 0x6E, 0x64, 0x65, 0x66, 0x20]);
  return buffer.subarray(0, 8).equals(signature);
}
Go
func IsH(data []byte) bool {
    signature := []byte{0x23, 0x69, 0x66, 0x6E, 0x64, 0x65, 0x66, 0x20}
    if len(data) < 8 {
        return false
    }
    return bytes.Equal(data[:8], signature)
}

API Endpoint

GET /api/v1/h
curl https://filesignature.org/api/v1/h

Related Formats