Get a Pentest and security assessment of your IT network.

Cyber Security

Password Entropy Calculator

TL;DR

This guide shows you how to calculate the entropy of a password – basically, how strong it is. We’ll use Python for an example, but the principles apply to any language or even manual calculation.

Calculating Password Entropy

  1. Understand Entropy: Entropy measures randomness. A higher entropy means more possible combinations and a stronger password. It’s calculated using logarithms (base 2 is common) and probabilities of each character appearing in the password.
    • A simple password like “123456” has very low entropy because it’s easy to guess.
    • A complex password with mixed case letters, numbers, and symbols will have high entropy.
  2. Determine the Character Set: First, you need to know what characters are allowed in your passwords.
    • Lowercase letters (a-z): 26 characters
    • Uppercase letters (A-Z): 26 characters
    • Numbers (0-9): 10 characters
    • Symbols: Varies, but let’s assume 32 for common symbols.
  3. Calculate the Total Possible Characters: Add up all the characters in your character set.

    For example, lowercase + uppercase + numbers + symbols = 26 + 26 + 10 + 32 = 94

  4. Determine Password Length: The length of the password is crucial. Longer passwords have exponentially more combinations.

    Let’s assume a password length of 8 characters.

  5. Calculate Total Possible Combinations: Raise the total number of possible characters to the power of the password length.
    94 ** 8

    This gives you approximately 5.96 x 1013 (almost 60 trillion) combinations.

  6. Calculate Entropy: Use the following formula:

    Entropy = log2(Total Possible Combinations)

    import math
    combinations = 94 ** 8
    entropy = math.log2(combinations)
    print(f"Password Entropy: {entropy}")

    This will output approximately 27.56 bits of entropy.

  7. Consider Character Frequency (Advanced): The above calculation assumes each character is equally likely. In reality, people tend to use certain characters more often.
    • If you know the frequency of each character in your passwords, you can refine the calculation for a more accurate result.
    • This involves calculating the probability of each character and using that in the entropy formula (Shannon Entropy). It’s more complex but provides a better estimate.
  8. Interpreting Entropy Values:
    • < 30 bits: Weak password – easily crackable.
    • 30-50 bits: Moderate password – requires more effort to crack.
    • > 50 bits: Strong password – very difficult to crack.
Related posts
Cyber Security

Zip Codes & PII: Are They Personal Data?

Cyber Security

Zero-Day Vulnerabilities: User Defence Guide

Cyber Security

Zero Knowledge Voting with Trusted Server

Cyber Security

ZeroNet: 51% Attack Risks & Mitigation