Skip to content
gohacks.dev
Security

Shannon Entropy Calculator

Calculate the Shannon entropy of strings in bits per character and in total, next to a character-pool estimate, to compare tokens, keys and passwords.

Free · No sign-up · Your inputs stay in your browser

Input

Calculate the Shannon entropy of strings

Output

4 strings

StringLengthBits per charTotal (observed)Pool estimate
correct horse battery staple283.49597.9164.7
Tr0ub4dor&3113.27836.172.3
kQ3n0gTgPm0w8r0oQ1m8m8t0QF2VZp2y324.179133.7190.5
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa330.0000.0155.1

Shannon entropy measures how evenly the characters of this particular string are spread, in bits per character; multiplied by the length it gives the information content of the string as observed. The pool estimate assumes every character was drawn at random from the character classes present, which is an upper bound for random tokens and badly overestimates human passwords: correct horse battery staple is about 44 bits as four random words. Secret scanners use high per-character entropy to spot keys in code.

Runs in this browser. Nothing you paste is sent to a server.

Reading the numbers

A random 32-character base64 token has close to 6 bits per character and about 190 bits in total; a string of one repeated character has 0. Secret scanners such as truffleHog flag high-entropy strings in code because random keys stand out from words.

Not a password strength meter

Both numbers describe the string, not how it was chosen. "correct horse battery staple" scores well on characters but has about 44 bits as four words picked at random from a 2,048-word list, and a human password that looks random often follows a guessable pattern. The password strength checker estimates guessing resistance instead.

Share

Frequently asked questions

What is a good entropy for an API key?
At least 128 bits from a cryptographic random generator, such as 32 hex characters or 22 base64url characters.
Why does the pool estimate differ from the observed entropy?
The pool estimate assumes every character was chosen at random from the classes present. The observed value measures the actual distribution of characters in this one string.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools