PPasswordForge
Get PasswordForge

PasswordForge/Guides

How to Determine Password Entropy in Bits

Learn to calculate true password entropy using log formulas. Understand why length matters more than complexity for security strength.

October 14, 2026 · 3 min read

Password entropy is calculated as length × log₂(charset_size) for random strings or words × log₂(wordlist_size) for passphrases. Higher bit counts indicate greater resistance to brute-force attacks, with 60+ bits generally considered secure for modern systems.

Why Entropy Matters More Than Complexity

Complexity refers to the variety of characters used, but entropy measures the total number of possible combinations. A password like "Password1!" looks complex because it mixes cases and symbols, but its entropy is low because humans follow predictable patterns when creating it. A longer passphrase using random words from a large dictionary often yields higher entropy despite appearing simpler. The goal is to maximize unpredictability. Understanding the math helps you choose between short, complex strings and longer, memorable phrases based on your specific security needs.

Calculating Random Password Entropy

For random passwords, entropy depends on the size of the character set and the length of the password. The formula is length × log₂(charset_size). The charset size is the total number of unique characters allowed. If you allow lowercase letters, uppercase letters, digits, and common symbols, the charset size is typically 94. If you restrict it to lowercase letters and digits only, the size is 36. Using the correct charset size is essential for accurate calculation. A larger charset increases entropy logarithmically, while increasing password length increases entropy linearly.

Consider a 12-character password using the full printable ASCII set (94 characters).

import math

charset_size = 94
length = 12

entropy_bits = length * math.log2(charset_size)
print(f"Entropy: {entropy_bits:.2f} bits")

The output is approximately 78.69 bits. This provides strong security for most accounts. Now compare this to a 12-character password restricted to lowercase letters and digits (36 characters).

import math

charset_size = 36
length = 12

entropy_bits = length * math.log2(charset_size)
print(f"Entropy: {entropy_bits:.2f} bits")

The output is approximately 62.11 bits. Restricting the character set significantly reduces entropy even when the length remains constant. This shows why expanding the allowed character set is an efficient way to boost strength for shorter passwords.

Calculating Diceware Passphrase Entropy

Diceware passphrases rely on selecting random words from a fixed list. The formula is number_of_words × log₂(wordlist_size). The standard EFF wordlist contains 7,776 words. Each word adds approximately 12.93 bits of entropy. Unlike random characters, where each character adds a fixed amount based on the charset, each word in a passphrase adds a consistent block of entropy. This linear relationship makes it easy to scale security by adding more words.

Calculate the entropy for a 4-word passphrase using the EFF wordlist.

import math

wordlist_size = 7776
number_of_words = 4

entropy_bits = number_of_words * math.log2(wordlist_size)
print(f"Entropy: {entropy_bits:.2f} bits")

The output is approximately 51.72 bits. While lower than the 12-character random password, this is often sufficient for many applications. If you increase the passphrase to six words, the entropy rises to about 77.58 bits, surpassing the random password example while remaining easier to memorize and type. This trade-off between length and complexity allows you to balance security requirements with usability.

The Role of Random Number Generators

The quality of the random number generator (RNG) directly impacts the actual entropy achieved. Standard JavaScript functions like Math.random() are not cryptographically secure. They use linear congruential generators that produce predictable sequences. If an attacker observes a few outputs, they can predict future values, effectively reducing the entropy regardless of the calculated bit count. For password generation, use crypto.getRandomValues(). This function utilizes a cryptographically secure pseudorandom number generator (CSPRNG), ensuring true unpredictability.

Using a weak RNG can make a theoretically high-entropy password vulnerable. Even if your math shows 80 bits of entropy, a predictable generator might only provide 30 bits of actual randomness. Always verify that your environment supports crypto.getRandomValues(). Most modern browsers do. This ensures that the randomness matches the calculated entropy, providing reliable security.

Verifying Entropy in Your Browser

You can verify entropy calculations directly in your browser console. This allows you to test different combinations of charset sizes and lengths instantly. By comparing calculated bits against known security thresholds, you can optimize your strategy. For instance, adding two words to a Diceware passphrase often provides better entropy gains than adding two characters to a random password, depending on your preferences for memorability versus typing speed.

Here is a function to compare both methods:

function calculateEntropy(type, length, size) {
    let entropy;
    if (type === 'random') {
        entropy = length * Math.log2(size);
    } else if (type === 'diceware') {
        entropy = length * Math.log2(size);
    }
    return entropy.toFixed(2);
}

console.log("Random (12 chars, 94 size):", calculateEntropy('random', 12, 94));
console.log("Diceware (4 words, 7776 size):", calculateEntropy('diceware', 4, 7776));

This code outputs the exact bit counts calculated in previous sections. You can adjust the parameters to see how changes affect strength. Tools like PasswordForge automate this process, displaying real entropy bits next to every generated password. This allows you to instantly verify that your chosen method meets your security requirements without manual calculation. The app uses crypto.getRandomValues() to ensure the randomness matches the calculated entropy, providing a reliable measure of strength for both random strings and Diceware passphrases.

Do it in PasswordForge

Everything in this guide works in the browser — open the tool and try it on your own input.

Open PasswordForge →

Questions people also ask

Is longer always better for password entropy?

No, length alone does not guarantee higher entropy if the characters are predictable. A long password made of common words or patterns has low entropy, whereas a shorter random string from a large character set can have higher entropy.

Why does the wordlist size affect passphrase entropy?

Entropy increases logarithmically with the size of the wordlist because each additional option in the list expands the total number of possible combinations. A larger wordlist means each word carries more information, thereby increasing the total bits of uncertainty for the passphrase.

Does special characters increase entropy significantly?

Yes, adding special characters increases the charset size, which exponentially raises the number of possible combinations for a given length. However, this benefit is only realized if the characters are chosen randomly rather than following predictable patterns.

How is entropy different from password strength scores?

Entropy is a mathematical measure of randomness and unpredictability, while strength scores are often heuristic ratings based on length and character variety. High entropy guarantees resistance to brute-force attacks, whereas a high strength score might still allow predictable patterns that reduce actual security.

More guides