KEY (.key)
.key file signature | application/x-pem-file
KEY is a PEM-encoded private key file format derived from the Public-Key Cryptography Standards (PKCS), originally developed by RSA Laboratories and commonly used by OpenSSL and related tools. It is used to store cryptographic private keys for SSL/TLS certificates, server authentication, code signing, and other applications that require secure key material. Because it may contain sensitive credentials, access should be restricted; some KEY files are legacy encodings or may be unencrypted despite the format's age.
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
Sources: Wikipedia
All Known Signatures
3 signature variants are documented for .key files across multiple sources.
| Hex Signature | Offset | Sources |
|---|---|---|
| 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 | 0 | Wikipedia |
| 2D 2D 2D 2D 2D 42 45 47 49 4E 20 44 53 41 20 50 52 49 56 41 54 45 20 4B 45 59 2D 2D 2D 2D 2D | 0 | Wikipedia |
| 2D 2D 2D 2D 2D 42 45 47 49 4E 20 52 53 41 20 50 52 49 56 41 54 45 20 4B 45 59 2D 2D 2D 2D 2D | 0 | Wikipedia |
Extension
.key
MIME Type
application/x-pem-file
Byte Offset
0
Risk Level
Safe
Validation Code
How to validate .key files in 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
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);
}
How to validate .key files in 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
/api/v1/key
curl https://filesignature.org/api/v1/key
See the full API documentation for all endpoints and parameters.
Related Formats
Frequently Asked Questions
What is a .key file?
A .key file is identified by the magic bytes 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 at byte offset 0. KEY is a PEM-encoded private key file format derived from the Public-Key Cryptography Standards (PKCS), originally developed by RSA Laboratories and commonly used by OpenSSL and related tools. It is used to store cryptographic private keys for SSL/TLS certificates, server authentication, code signing, and other applications that require secure key material. Because it may contain sensitive credentials, access should be restricted; some KEY files are legacy encodings or may be unencrypted despite the format's age.
What are the magic bytes for .key files?
The magic bytes for KEY files are 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 at byte offset 0. These bytes uniquely identify the file format regardless of the file extension.
How do I validate a .key file?
To validate a .key file, read the first bytes of the file and compare them against the known magic bytes (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) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.
What is the MIME type for .key files?
The primary MIME type for .key files is application/x-pem-file.
Is it safe to open .key files?
KEY (.key) files are generally safe to open. They are classified as low risk because they primarily contain data rather than executable code. However, always ensure files come from a trusted source.