KEY (.key)
.key file signature | application/octet-stream
PEM encoded X.509 PKCS#1DSAprivate key
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/octet-stream
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.
Frequently Asked Questions
What is a .key file?
A .key file is a KEY file. PEM encoded X.509 PKCS#1DSAprivate key
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?
There is no officially registered MIME type for .key files. Systems typically use application/octet-stream as a generic fallback when handling this format.
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.