Compressed archive file (.lha)
.lha file signature | application/x-lzh-compressed
LHA is a compressed archive file format originally developed by Haruyasu Yoshizaki and later supported by various open-source implementations. It is used for packaging multiple files into a single archive, reducing storage use and simplifying distribution on legacy systems, especially in Japanese computing environments and older software collections. The format is now largely considered legacy; as with other archives, files from untrusted sources should be opened with caution because they may contain harmful content.
Magic Bytes
Offset 2
2D 6C 68
Sources: Gary Kessler
Extension
.lha
MIME Type
application/x-lzh-compressed
Byte Offset
2
Risk Level
Safe
Validation Code
How to validate .lha files in Python
def is_lha(file_path: str) -> bool:
"""Check if file is a valid LHA by magic bytes at offset 2."""
signature = bytes([0x2D, 0x6C, 0x68])
with open(file_path, "rb") as f:
f.seek(2)
return f.read(3) == signature
How to validate .lha files in Node.js
function isLHA(buffer: Buffer): boolean {
const signature = Buffer.from([0x2D, 0x6C, 0x68]);
if (buffer.length < 5) return false;
return buffer.subarray(2, 5).equals(signature);
}
How to validate .lha files in Go
func IsLHA(data []byte) bool {
signature := []byte{0x2D, 0x6C, 0x68}
if len(data) < 5 {
return false
}
return bytes.Equal(data[2:5], signature)
}
API Endpoint
/api/v1/lha
curl https://filesignature.org/api/v1/lha
See the full API documentation for all endpoints and parameters.
Related Formats
Frequently Asked Questions
What is a .lha file?
A .lha file is a Compressed archive file file. LHA is a compressed archive file format originally developed by Haruyasu Yoshizaki and later supported by various open-source implementations. It is used for packaging multiple files into a single archive, reducing storage use and simplifying distribution on legacy systems, especially in Japanese computing environments and older software collections. The format is now largely considered legacy; as with other archives, files from untrusted sources should be opened with caution because they may contain harmful content.
What are the magic bytes for .lha files?
The magic bytes for Compressed archive file files are 2D 6C 68 at byte offset 2. These bytes uniquely identify the file format regardless of the file extension.
How do I validate a .lha file?
To validate a .lha file, read the first bytes of the file and compare them against the known magic bytes (2D 6C 68) at offset 2. This is more reliable than checking the file extension alone, as extensions can be renamed.
What is the MIME type for .lha files?
The primary MIME type for .lha files is application/x-lzh-compressed.
Is it safe to open .lha files?
Compressed archive file (.lha) 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.