KEY

application/octet-stream

Safe

Magic Bytes

Offset: 0
2D 2D 2D 2D 2D 42 45 47 49 4E 20 50 52 49 56 41 54 45 20 4B 45 59 2D 2D 2D 2D 2D

The KEY file format, identified by its PEM header, represents a private cryptographic key associated with OpenSSL and PKCS standards. These files store sensitive cryptographic data required for SSL/TLS server authentication, SSH remote access, and digital signature generation. Although the text-based format itself poses no execution risk, the contained private key material is critical for security infrastructure and must be strictly protected from unauthorized access to prevent credential compromise.

Extension

.key

MIME Type

application/octet-stream

Byte Offset

0

Risk Level

Safe

Validation Code

How to validate .key files in Python

Python
def is_key(file_path: str) -> bool:
    """Check if file is a valid KEY by magic bytes."""
    signature = bytes([0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x20, 0x4B, 0x45, 0x59, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D])
    with open(file_path, "rb") as f:
        return f.read(27) == signature

How to validate .key files in Node.js

Node.js
function isKEY(buffer: Buffer): boolean {
  const signature = Buffer.from([0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x20, 0x4B, 0x45, 0x59, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D]);
  return buffer.subarray(0, 27).equals(signature);
}
Go
func IsKEY(data []byte) bool {
    signature := []byte{0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x20, 0x4B, 0x45, 0x59, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D}
    if len(data) < 27 {
        return false
    }
    return bytes.Equal(data[:27], signature)
}

API Endpoint

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

Related Formats