Back to cheatsheets
Passwords
Passphrase Generation (EFF Diceware)
Generate memorable EFF Diceware passphrases with CSPRNG selection — ~77 bits at 6 words.
What you'll learn
- Diceware passphrase generator
- Entropy per word count
How to use these snippets
- Click the Copy button next to any snippet to copy it to your clipboard.
- Paste the code into your project, IDE, or terminal.
- Replace placeholder values (like
example.comoryour-secret) with your actual data. - Review the code comments for important security notes and caveats.
- Try the interactive related tool to see the concept in action.
Code Snippets
Copy-paste code snippets
2 ready-to-use snippets for passphrase generation (eff diceware). Click copy and paste into your project.
Diceware passphrase generator
// Requires EFF word list (7,776 words)
const WORDS = ['apple', 'brave', 'cloud', ...]; // eff.json
function passphrase(wordCount = 6) {
const arr = new Uint32Array(wordCount);
crypto.getRandomValues(arr);
return Array.from(arr, n =>
WORDS[n % WORDS.length]
).join('-');
}
// 6 words × log2(7776) = ~77.5 bits of entropy
Entropy per word count
function passphraseEntropy(words) {
return (Math.log2(7776) * words).toFixed(1);
}
// 4 words → 51.6 bits
// 5 words → 64.5 bits
// 6 words → 77.5 bits
// 7 words → 90.5 bits
// 8 words → 103.4 bits
Tool
Related ShieldX tool
Try this concept hands-on with the interactive tool.
100% Free · No signup · No cost
Generate something unguessable right now
148 bits of entropy, a crack-time estimate you can trust, and a clipboard that clears itself after 30 seconds.
Part of the Toolly ecosystem · secure.toolly.site