Hashcat Token Length Exception: Every Cause, One Fix

"Token length exception" means hashcat rejected a line before cracking it. The six real causes, in the order they actually happen, and the command for each.

Hashcat says Token length exception and exits without trying a single password. That is not a bug and not a corrupt hash: hashcat read your file, compared each line against the structure the selected mode expects, and threw the line away because its length did not fit. The fix is almost always in the file, not in the hash.

This page lists the causes in the order they actually occur, because the popular answers online start with the rarest one. One of them is a well-ranked page that tells you to "reduce the token length in the hashcat config file" — hashcat has no such setting, so ignore that advice when you find it.

What the message actually tells you

MessageMeaning
Token length exceptionAt least one line did not match the length pattern of mode -m.
Token length exception: 1/1 hashesExactly one line was rejected and it was the only line in the file. The file has one problem, not a mixture.
Token length exception: 3/12 hashesGood news: nine lines were accepted. Only the three rejected ones need work.
No hashes loadedEvery line was rejected. Usually a whole-file problem — encoding, line endings, or a completely wrong mode.
Token encoding exceptionThe bytes themselves are not the encoding hashcat expects. Almost always UTF-16 or a BOM.
ExhaustedNot the same error. The hashes loaded, the wordlist and rules ran out without a match.

1. Windows line endings and trailing spaces

The most common cause by far. A hash copied out of a web page, a chat message or a Windows editor brings a carriage return (\r) or a trailing space with it, so the line is one or two characters longer than the mode allows.

cat -A hashes.txt
# a bad line ends like this:  31d6cfe0d16ae931b73c59d7e0c089c0^M$
# a good line ends like this: 31d6cfe0d16ae931b73c59d7e0c089c0$

sed -i 's/\r$//' hashes.txt     # strip CR
sed -i 's/[[:space:]]*$//' hashes.txt

dos2unix hashes.txt              # or the packaged equivalent

Run cat -A before anything else. If you see ^M, you are finished — that was the whole problem.

2. A username stuck to the front of the hash

admin:31d6cfe0d16ae931b73c59d7e0c089c0 is not an MD5 hash, it is a line with a hash in it. Two ways out:

# Let hashcat ignore the user field itself
hashcat -m 0 --username hashes.txt rockyou.txt

# Or keep only the last colon-separated field
awk -F: '{print $NF}' hashes.txt > clean.txt

Watch out for secretsdump and mimikatz output, which is user:rid:lmhash:nthash::: — the field you want is the fourth, and it is the NTLM (mode 1000), not the LM.

3. The mode and the hash belong to different algorithms

Every mode has a fixed shape. -m 0 (MD5) wants 32 hex characters; hand it a 64-character SHA-256 and it rejects the line. Before guessing, ask hashcat what it thinks the hash is:

hashcat --identify hashes.txt

# older builds that predate --identify: browse the canonical example for a mode
hashcat --example-hashes | less
hashcat --example-hashes | grep -A2 'Hash Mode #1000'

Two modes can share a length — MD5 and NTLM are both 32 hex characters — so no length check will catch that mistake. Those lines load fine and simply never crack. If a run loads hashes but recovers nothing, check the mode before blaming the wordlist.

4. Salt in the wrong place

Salt modes expect the salt as part of the line, in a documented order. -m 10 is md5($pass.$salt) and takes hash:salt; -m 20 takes salt:hash. Give -m 10 a bare hash and it fails the length check, because the line is missing its second field.

hashcat --example-hashes | grep -A4 'Hash Mode #10'   # exact expected format

5. UTF-16 or a byte-order mark

PowerShell's Out-File and some Windows editors write UTF-16 by default. Every ASCII character becomes two bytes, so a 32-character hash arrives as 64 bytes of something hashcat cannot parse. The message is usually Token encoding exception.

file hashes.txt
# hashes.txt: Unicode text, UTF-16, little-endian

iconv -f UTF-16 -t UTF-8 hashes.txt > hashes-utf8.txt

6. A hash that was split across lines

Long formats — bcrypt ($2y$, 60 characters), sha512-crypt ($6$), KeePass, 1Password — are easy to break when copying from a terminal that wrapped the line. A 59-character bcrypt string fails the length check with the same message as everything else.

awk 'length($0) > 0 { print length($0) ": " substr($0,1,20) "..." }' hashes.txt

Every line of the same mode should report the same length. If one line is short, compare it against --example-hashes and re-extract it with the matching *2john script instead of retyping it.

7. Extra fields from a converter

Converter scripts do not always emit exactly what hashcat wants. A known example: rar2john appends a :1:: suffix that -m 12500 rejects, and the hash may actually be mode 23800. If a *2john output fails, check the mode against the hash's own structure before trimming anything.

The five-command diagnostic

cat -A hashes.txt                      # 1. hidden CR, trailing spaces
file hashes.txt                        # 2. UTF-16 or BOM
awk -F: '{print NF}' hashes.txt | sort -u   # 3. field count (1 = no salt/prefix)
hashcat --identify hashes.txt          # 4. what mode does this look like
hashcat -m <mode> hashes.txt rockyou.txt --quiet   # 5. does one line load now

Confirm the fix

A correct run says Recovered........: 0/1 (0.00%) Digests and starts printing a speed — that means the hash loaded. Zero recovered after a full wordlist is a different problem: the password is not in that wordlist, not that the file was wrong.

Frequently asked

Is my hash corrupted?

Rarely. A hash that came out of a tool is intact; the file around it is usually the problem. Check line endings and prefixes first, then verify the length against --example-hashes.

Why did hashcat accept 9 of my 12 hashes?

Different lines, different problems. Nine matched the mode, three did not. Fix the three individually rather than rebuilding the whole file.

Does --identify exist on my version?

hashcat --identify arrived with hashcat 7. If your distro shipped an older build, run hashcat --help | grep identify; when that prints nothing, use --example-hashes and compare lengths manually.

Not sure what the string in front of you even is? The Hash & JWT Inspector identifies MD5, SHA-family, bcrypt, Argon2 and JWT payloads by structure. For the other classic failure, see John the Ripper cheat sheet, and for the tool itself the hashcat guide or John the Ripper guide.

See also: Hashcat "No Hashes Loaded": 5 Causes — the parent error this variant belongs to.

See also: Hashcat "No Hashes Loaded": 5 Causes — the parent error this variant belongs to.


Keep reading

Related articles

Browse all articles