Toolvito

Works on this device

API Key Entropy Checker

Paste an API key or a secret token to see how many bits of randomness it can hold. The tool finds the alphabet of the key, leaves out a fixed part at the start, and looks for obvious patterns. The check runs in this page; the key box is masked, and the key is not sent or saved. It is safer to check a key that is not in use.

Check a key

Paste a key. The tool finds its alphabet, counts the bits it can hold and looks for obvious patterns.

Key and settings

The box is masked; choose Show to see it. It is never saved or written into a file. It is safer to check a key that is not in use, or a new one made the same way.

A part that is the same in every key of this kind, such as a short name of the service. It is taken out of the count.

For the table of lengths in each alphabet.

The check runs in this page. The key is not sent or saved.

The result will show here

Paste a key, or choose Try an example.

How to use the API key entropy checker

  1. Choose Check a key and paste the key. The box is masked: choose Show to see the key, and Hide to mask it again. The result follows as you type.
  2. If every key of this kind starts with the same text, such as a short name of the service, type it in Fixed part at the start. It is the same for everyone, so it adds nothing and is taken out of the count.
  3. Leave the alphabet on Find it from the key, or choose it yourself if you know how the key was written.
  4. Read the bits, the checks for patterns and the table of lengths. Choose Length needed for a strength to plan a new key without typing one.
  5. Copy the result, print it, or download it as a CSV file. The CSV file has your settings and the results, but not the key.

Keep your key safe

  • The check runs in this page. The page does not send the key anywhere and does not save it. The key box is never kept on this device and never put into the address of the page. Reset and leaving the page mask it again.
  • The result does not repeat the key. In the CSV file the row of the key says "(left out of this file)", and the copied result and the printed page do not show the key either. The fixed part at the start is not secret, so it is in the CSV file as you typed it.
  • It is still safer not to paste a key that is in use. A program on your device or a browser add-on can see what you paste, and Show lets a person beside you see it. Check a new key made the same way, or a key that you have already revoked.
  • If a key was ever pasted into a place you do not trust, make a new one and revoke the old one.

How the bits are worked out

Entropy if the key is random = characters counted × log2(characters in the alphabet). The fixed part at the start and the = padding at the end are not counted.

This is the most the key can hold. It holds only if every character was picked by a good random generator. The tool cannot tell how a key was made. A key typed by a person, or made from a time, a counter, a name or a weak generator, can look random and still be easy to guess.

How the alphabet is found

The tool tries these rules in order and takes the first that fits the key without its fixed part:

  • Only digits: digits 0 to 9 (10 characters, 3.32 bits each).
  • Only 0 to 9 and a to f, or only 0 to 9 and A to F: hexadecimal (16, 4 bits each).
  • Only A to Z and 2 to 7, or only a to z and 2 to 7, with = only at the end: Base32 (32, 5 bits each).
  • Only small letters and digits: small letters and digits (36, 5.17 bits each). Only capital letters and digits: capital letters and digits (36).
  • Only letters and digits: letters and digits (62, 5.95 bits each). Base64 without + and / looks the same, so the tool takes the smaller count. Choose Base64 yourself if you know.
  • Letters, digits, + and /, with at most two = at the end: Base64 (64, 6 bits each).
  • Letters, digits, - and _, with at most two = at the end: Base64url (64, 6 bits each).
  • Anything else: the kinds of characters that appear (small letters 26, capital letters 26, digits 10, symbols 33).

Checks for obvious patterns

Each check gives the chance that a random key of the same length and alphabet would show the same thing. A check is a sign of a pattern when that chance is below 1%. The checks are: the longest run of one character (at most (n − r + 1) × A^−(r−1)), the longest run in order such as abcd or 4321 (at most (n − r + 1) × 2 × A^−(r−1)), a kind of character of the alphabet that never appears (((A − c) ÷ A)^n), and a key that repeats itself (it then holds at most the bits of the repeating piece). Here n is the length, r the length of the run, A the size of the alphabet and c the number of characters of that kind.

No sign of a pattern does not prove that a key is random. A sign of a pattern means the key should be checked, and usually replaced by a new key from a secure random generator.

Worked example

The example key is demo_ followed by 32 characters from 0 to 9 and a to f. With demo_ as the fixed part, 32 characters are counted in hexadecimal: 32 × log2(16) = 128 bits. No check shows a sign of a pattern.

For 128 bits you need 32 hexadecimal characters, 26 Base32 characters or 22 Base64url characters. 16 random bytes written in Base64 with padding take 24 characters.

Limits you should know

  • The bits are an upper limit. They are real only when the key comes from a good random generator.
  • The checks find only obvious patterns. They cannot find a key made from a secret seed, a hash of a guessable value or a weak generator.
  • The tool counts keyboard characters only (no spaces). Spaces at the start and the end of the key are left out. It does not check whether a key is valid for a service, and it does not know the formats of any company.

Related tools