What a random password is, and why random matters
A password protects an account only as well as it resists guessing. People who make up passwords follow habits: a word, a capital at the start, a number and a symbol at the end. Attackers know those habits and try them first, so a password that looks complex can fall in minutes.
A random password has no habits to exploit. Every character is picked by a cryptographic random generator, so the only way to find it is to try the possible passwords one by one. How many there are depends on two things you control: the length and the set of characters.
This generator makes those passwords in your browser and tells you exactly how strong they are, in bits of entropy, for the settings you chose.
How password entropy is measured
Entropy counts the possible passwords as a power of two. A password with 80 bits of entropy is one of 2^80 equally likely passwords. Each extra bit doubles the work for an attacker.
For a password of length L drawn from an alphabet of N characters, the count is N^L and the entropy is L × log2(N). Length multiplies; a bigger alphabet only adds a little per character.
| Characters | Alphabet size | Bits per character | 16 characters |
|---|---|---|---|
| Digits only | 10 | 3.32 | 53 bits |
| Lowercase | 26 | 4.70 | 75 bits |
| Lower and upper | 52 | 5.70 | 91 bits |
| Letters and digits | 62 | 5.95 | 95 bits |
| Letters, digits and 28 symbols | 90 | 6.49 | 104 bits |
The figure only holds when the password really is random. A made-up password of the same length has far less, because its characters are not independent choices.
Why "one of each kind" changes the count
Many policies want at least one uppercase letter, one digit and one symbol. A generator that forces this produces fewer possible passwords than one that does not, because passwords missing a kind are ruled out.
This tool counts that exactly with inclusion and exclusion: all passwords over the full alphabet, minus those missing each kind, plus those missing two kinds, and so on. For 20 characters over 90 symbols the loss is a fraction of a bit, which is why the setting is on by default.
How this generator picks characters
Randomness comes from crypto.getRandomValues, the browser’s cryptographically secure generator. It is the same source the browser uses for its own keys.
A common bug in password generators is modulo bias. Taking a random 32-bit number and computing value % 90 makes some characters slightly more likely than others, because 2^32 is not a multiple of 90. This tool uses rejection sampling instead: it throws away the few values at the top of the range that would cause bias and draws again.
limit = 2^32 - (2^32 mod 90)
repeat:
value = random 32-bit number
until value < limit
character = alphabet[value mod 90]When you ask for one of each kind, the tool draws a whole password and keeps it only if every kind is present. Redrawing whole passwords keeps the result uniform over the passwords that qualify. Patching a password afterwards, for example by swapping in a digit at a random place, would not.
What this tool does and does not do
- It generates one, five or ten passwords from 1 to 256 characters, from the kinds of characters you choose.
- It can leave out look-alike characters (
I,l,1,|,O,0,o) for passwords someone must read aloud or type from paper. - It shows the exact entropy for the current settings and the size of the alphabet.
- It does not store, log or send any password. Nothing leaves the page unless you copy it.
- It does not check a password you made yourself. Use the password strength checker for that.
The symbol set leaves out the double quote, single quote, backslash and backtick. Those characters often need escaping in shells, JSON, YAML and environment files, and a wrongly escaped password is a common cause of failed logins after a deploy.
How to generate a password
- Set the length. For accounts a person types, 16 to 20 characters is a good range. For secrets only machines read, go longer.
- Choose the kinds of characters. Keep all four unless a system rejects some.
- Tick "Leave out look-alikes" if the password will be read by a person.
- Keep "At least one of each chosen kind" on if a password policy requires it.
- Copy one password. Press Generate again for a fresh set; each set is independent.
Copy only the password you use. The clipboard can be read by other apps on some systems, so paste it into your password manager or the target system right away.
Where generated passwords fit in identity work
Random passwords are most useful where no person has to remember them, or where a password manager remembers them for the person.
Admin and break-glass accounts
An identity provider’s first admin account, or an emergency account kept for when single sign-on fails, should have a long random password kept in a vault. In Keycloak this means the initial admin of the master realm, and any realm admin you create for recovery. Pair it with a second factor.
Temporary passwords for new users
When an admin sets a first password for a user, Keycloak can mark it temporary so the user must change it at first sign-in. A random temporary password avoids the common pattern of a shared default such as the company name and the year.
Service and database accounts
Keycloak connects to its database with a user and password. That password is read from configuration by a machine, so it can be long and use letters and digits only, which avoids escaping problems. For OAuth clients, use the client secret generator instead, which works in bytes and Base64url.
Meeting a password policy
Keycloak checks new passwords against the realm’s password policy, which can require a minimum length, digits, lowercase and uppercase letters, special characters, and more. Match the generator’s settings to the policy before setting a password, so it is not rejected.
How long should a password be?
It depends on how the password could be attacked.
| Situation | Suggested entropy | Example setting |
|---|---|---|
| Online sign-in with rate limits or lockout | 50 bits or more | 10 characters, all kinds |
| Account whose hash might be stolen | 80 bits or more | 13 characters, all kinds |
| Admin, vault master or break-glass account | 100 bits or more | 16 characters, all kinds |
| Secret only machines read | 128 bits or more | 22 letters and digits, or a generated key |
These are working guidelines, not a standard. The point is the gap: an online attacker is slowed by the server, while an attacker with a stolen hash can guess as fast as their hardware allows.
Common mistakes and how to avoid them
- Relying on many kinds of characters instead of length. Twelve characters from 90 symbols (78 bits) is only slightly stronger than 16 lowercase letters (75 bits), and much harder to type. Add length first.
- Editing the generated password to make it easier. Any change a person makes reintroduces a pattern.
- Reusing one generated password in several places. A strong password reused on a breached site is no longer secret.
- Pasting a password with a trailing space or line break. Some systems keep it as part of the password.
- Putting quotes or backslashes in passwords that go into config files. The default symbol set here avoids them for that reason.
Security notes
NIST Special Publication 800-63B, the US guidance on authentication, advises verifiers to accept long passwords (at least 64 characters), to check new passwords against lists of known compromised values, and not to impose composition rules or regular forced changes. A random password from a manager satisfies all of that without effort from the user.
How the server stores the password matters as much as the password. A system should store it with a slow, salted function such as Argon2, scrypt, bcrypt or PBKDF2, never a plain hash. See the PBKDF2 hasher for how that works.
A password generated here never leaves your browser. Even so, generate production credentials on a device you trust, and close the tab when you are done.
Best practices
- Store every generated password in a password manager or a secrets vault, never in a note or a chat message.
- Use a different password for every account and every environment.
- Turn on a second factor for any account that matters, especially admin accounts.
- Prefer passkeys or single sign-on where the service supports them; then most users have no password to manage at all.
- Rotate a password when it may have been exposed, not on a fixed calendar.