LM (LAN Manager) Hash
The LM (LAN Manager) hash is a legacy, highly insecure Windows password hashing algorithm from the 1980s that splits passwords into two 7-character, uppercase DES-encrypted chunks.
How LM Hash Works?
LM hashing follows a fixed and predictable process:
1. Password Normalization
LM is case-insensitive, before hashing, the password get converted to uppercase and padded or truncated to 14 bytes
2. Splitting the Password
The 14-byte string is split into two 7-byte halves (chunks)
3. Creating DES Keys
LM was built on top of DES instead of designing a new cryptographic function. Each 56-bit (7-byte) half is converted into a 64-bit (8-byte) DES key by adding parity bits (1 per byte)
by converting the seven bytes into a bit stream with the most significant bit first, and inserting a null bit after every seven bits, so for exmaple 1010100 becomes 10101000, this generates the 64 bits needed for a DES key.
The parity bit is not fixed. It is calculated based on the number of 1s in the 7-bit data portion of the byte:
- If the 7 data bits already contain an odd number of 1s, the parity bit is set to 0 (to keep the total odd).
- If the 7 data bits contain an even number of 1s, the parity bit is set to 1 (to make the total odd).
This ensures that every final 8-bit DES key byte always has odd parity. this is required mainly for historical hardware reliability reasons, not cryptographic strength.
4. DES Encryption
Each of the two keys is used to DES-encrypt the constant ASCII string:
KGS!@#$%
Applied separately to both halves, resulting in two parts 8-byte ciphertext values.
It always uses KGS!@#$% as the constant string. This is not random, per-password, or configurable. It’s hardcoded into the LM hashing algorithm.
5. Final LM Hash Output
These two ciphertext values are concatenated to form a 16-byte value, which is the LM hash.
Special Case: Passwords ≤ 7 Characters
If a password is 7 characters or shorter, that second half will always produces the same result, which is:
aad3b435b51404ee