ASC (.asc)
.asc file signature | application/octet-stream
Armored PGP public key
Magic Bytes
Offset 0
2D 2D 2D 2D 2D 42 45 47 49 4E 20 50 47 50 20 50 55 42 4C 49 43 20 4B 45 49 20 42 4C 4F 43 4B 2D 2D 2D 2D 2D
Sources: Wikipedia
Extension
.asc
MIME Type
application/octet-stream
Byte Offset
0
Risk Level
Safe
Validation Code
How to validate .asc files in Python
def is_asc(file_path: str) -> bool:
"""Check if file is a valid ASC by magic bytes."""
signature = bytes([0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20, 0x50, 0x47, 0x50, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49, 0x43, 0x20, 0x4B, 0x45, 0x49, 0x20, 0x42, 0x4C, 0x4F, 0x43, 0x4B, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D])
with open(file_path, "rb") as f:
return f.read(36) == signature
How to validate .asc files in Node.js
function isASC(buffer: Buffer): boolean {
const signature = Buffer.from([0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20, 0x50, 0x47, 0x50, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49, 0x43, 0x20, 0x4B, 0x45, 0x49, 0x20, 0x42, 0x4C, 0x4F, 0x43, 0x4B, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D]);
return buffer.subarray(0, 36).equals(signature);
}
How to validate .asc files in Go
func IsASC(data []byte) bool {
signature := []byte{0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20, 0x50, 0x47, 0x50, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49, 0x43, 0x20, 0x4B, 0x45, 0x49, 0x20, 0x42, 0x4C, 0x4F, 0x43, 0x4B, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D}
if len(data) < 36 {
return false
}
return bytes.Equal(data[:36], signature)
}
API Endpoint
/api/v1/asc
curl https://filesignature.org/api/v1/asc
See the full API documentation for all endpoints and parameters.
Frequently Asked Questions
What is a .asc file?
A .asc file is a ASC file. Armored PGP public key
What are the magic bytes for .asc files?
The magic bytes for ASC files are 2D 2D 2D 2D 2D 42 45 47 49 4E 20 50 47 50 20 50 55 42 4C 49 43 20 4B 45 49 20 42 4C 4F 43 4B 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 .asc file?
To validate a .asc 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 47 50 20 50 55 42 4C 49 43 20 4B 45 49 20 42 4C 4F 43 4B 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 .asc files?
There is no officially registered MIME type for .asc files. Systems typically use application/octet-stream as a generic fallback when handling this format.
Is it safe to open .asc files?
ASC (.asc) 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.