# What is entropy in a secret? Bits of randomness

> Entropy measures how unpredictable a secret is, in bits: each bit doubles the guesses needed. How to count it for random keys, and why length alone can mislead.

URL: https://crunu.com/learn/entropy
Language: en
Updated: 2026-10-30

Entropy, for a secret, is a measure of how unpredictable it is, expressed in bits: a value with n bits of entropy is one of 2ⁿ equally likely possibilities, so each extra bit doubles the number of guesses an attacker needs to be sure of finding it.

## Where the idea comes from

NIST defines entropy as "a measure of the disorder or randomness in a closed system", with the formula from information theory ([NIST glossary](https://csrc.nist.gov/glossary/term/entropy)). For secrets, the practical version is simple: if every possible value is equally likely, entropy is log₂ of the number of possible values.

## Counting it for random secrets

For a value made of characters chosen independently and uniformly at random, bits = length × log₂(alphabet size). For random bytes, it is simpler still: 8 bits per byte, whatever encoding you print them in.

| Secret                       | Characters       | Bits            |
| ---------------------------- | ---------------- | --------------- |
| 16 random bytes as hex       | 32               | 128             |
| 32 random bytes as Base64    | 44, with padding | 256             |
| 40 random letters and digits | 40               | about 238       |
| random UUID, version 4       | 36               | 122 random bits |

The UUID line is a reminder that a random-looking format isn't always a secret format. RFC 9562 says implementations "SHOULD NOT assume that UUIDs are hard to guess" and that they "MUST NOT be used as security capabilities" ([RFC 9562](https://www.rfc-editor.org/rfc/rfc9562)).

## The formula only works for random choices

Entropy counts the choices behind a value, not the value itself. A 20-character password that a person made up has far less entropy than 20 random characters, because people choose words, dates and patterns that attackers try first. The same goes for a "random" key built with a non-secure generator, which may be predictable from earlier output; see [CSPRNG](https://crunu.com/learn/csprng).

So "how long is it?" is the wrong question. "How was it chosen, from how many possibilities?" is the right one.

## How much is enough

256 bits matches the key size of AES-256 and the output of HMAC-SHA256, and is a common default for generated secrets; 128 bits is a usual floor. Values people must remember will always have much less, which is why systems that rely on passwords add something else, such as a random second secret or slow key derivation.

## Common mistakes

- **Counting the encoding, not the bytes.** Encoding 16 random bytes as Base64 makes the string longer, not stronger.
- **Using identifiers as secrets.** UUIDs, timestamps and database IDs aren't designed to be unguessable.
- **Trusting a strength meter on a generated value** instead of knowing how it was generated.

## Entropy in Crunu

Your account key in Crunu is derived from your password and a **Secret Key**, a value generated on your device and never sent to the server. A Secret Key is written as `K1-` followed by groups of 6, 6, 5, 5, 5 and 5 characters from a 31-character alphabet that leaves out easily confused characters such as 0, 1, I and O. The first group is a non-secret account label, so the secret part is 26 characters: 26 × log₂ 31 ≈ 128.8 bits. Because every password guess against a stolen database would also need the Secret Key, a weak password alone isn't enough to break in. See [Secret Key](https://crunu.com/learn/secret-key) and [key derivation](https://crunu.com/learn/key-derivation).

The **Generate** button in the environment editor creates 40 random letters and digits, about 238 bits, with the browser's secure generator.

## Sources

- [NIST CSRC glossary: entropy](https://csrc.nist.gov/glossary/term/entropy), checked October 30, 2026.
- [RFC 9562: Universally Unique IDentifiers (UUIDs)](https://www.rfc-editor.org/rfc/rfc9562), checked October 30, 2026.
