Guide
Generating Secrets and Hashing Passwords Safely
A practical guide to choosing random passwords and tokens, deriving and storing password hashes, signing tokens, encrypting with authenticated modes and measuring entropy.
Secrets and hashes are different things with different rules. A secret (a password, API key or session token) must never be reused or stored in plaintext; a password hash must be salted, slow and verified in constant time; a message authentication code or signature proves integrity; and encryption hides content while an authenticated mode also detects tampering. Picking the right one is most of the work.
01Randomness, hashing and encryption are not interchangeable
- Randomness: generate secrets with the platform CSPRNG, never Math.random, and record the true entropy from the alphabet or byte length.
- Password hashing: use a salted key-derivation function (Argon2id, bcrypt or PBKDF2) with a high work factor; a plain SHA-256 digest is not a password hash.
- Authentication: HMAC or a signature proves who created a message; base64url is only an encoding and proves nothing.
- Encryption: use an authenticated mode such as AES-GCM and never reuse a nonce with the same key.
Browser tools have limits
A browser page can generate randomness and run compact standards such as PBKDF2, HMAC and AES-GCM honestly. It cannot safely re-implement large primitives such as Argon2 or bcrypt, so a good tool states that limit instead of pretending to verify them.
02What to keep where
Generate secrets in the browser and paste them straight into a secret manager. Hash passwords on the server with the library that will verify them. Keep private keys out of web pages entirely. When a browser tool is used for development, treat every value as a real secret: nothing should be logged, placed in a URL or committed.
Frequently asked questions
- Is SHA-256 good enough for passwords?
- No. A plain hash is fast and unsalted, so an attacker can test billions of guesses per second. Use a dedicated password hash such as Argon2id, bcrypt or PBKDF2 with a high work factor and a per-password salt.
- Why does the tool not verify my bcrypt hash?
- bcrypt and Argon2 are large, stateful primitives. Re-implementing them correctly in a browser bundle is risky, so the password hash tool inspects their encoding and tells you to verify server-side with the library that produced the hash.
- Can I encrypt in the browser?
- Yes, for text you paste, using an authenticated mode such as AES-GCM with a fresh nonce. Remember that key management, transport security and endpoint trust are still yours.
Sources
- NIST SP 800-63B: Digital Identity Guidelines — Authentication and Lifecycle Management — NIST (accessed 2026-10-05)
- RFC 8018: PKCS #5 — Password-Based Cryptography Specification v2.1 — IETF (accessed 2026-10-05)
- NIST SP 800-38D: GCM Recommendation — NIST (accessed 2026-10-05)
Test this in your browser
The tool runs entirely in your browser; the input you use never leaves it.
About the author
Gampangin builds and maintains free, browser-based developer tools and the documentation that makes them trustworthy. The organization is accountable for every page published on this site.