How passphrase encryption works: AES-GCM, salt and PBKDF2 in plain words

How a passphrase becomes a key, what the salt and IV are for, why the same message never locks the same way twice, and why the passphrase matters most.

Open the Text encryption Free, in your browser, nothing uploaded.

Encrypting text with a passphrase means turning a readable message into a string that looks like noise, which only someone who knows the passphrase can turn back. This guide explains the three parts that make that safe: a slow key recipe, a random salt and nonce, and a built-in tamper check. It is for anyone who wants to keep a note, a recovery code or a message private, and for students meeting real cryptography for the first time. A strong passphrase matters most, so make one with password generator and test it with password strength; to prove a file has not changed rather than hide it, use hash checker.

What it is

A cipher such as AES-256 needs a key of exactly 256 random bits. A passphrase like “orbit lantern cobalt meadow” is not that, so it goes through a key derivation function first:

key = PBKDF2(passphrase, salt, 600,000 rounds, SHA-256)

  • PBKDF2 runs a hash function over and over. Each guess an attacker makes costs those same 600,000 rounds, so guessing billions of passphrases becomes very slow.
  • The salt is 16 random bytes, made fresh for every lock. Two people with the same passphrase still get different keys, and an attacker cannot pre-compute a table of common passphrases.

Then AES-GCM encrypts the message with that key and a 12-byte random IV (initial value, also called a nonce). GCM adds a 16-byte authentication tag: a check that fails if a single bit of the locked text, salt or IV is changed, so unlocking refuses rather than giving you altered words.

The output packs it all together: fibub1. + the number of rounds + . + base64url of salt (16 bytes) + IV (12 bytes) + encrypted text and tag. Base64url turns every 3 bytes into 4 letters, digits, - or _, so the string is safe to paste into email or chat. Its length is

14 + ⌈(44 + message bytes) × 4 ÷ 3⌉ characters

where 44 is the salt, IV and tag together, and 14 is the fibub1.600000. prefix.

How to use it

  1. Open the text encryption page and choose Lock text.
  2. Type or paste the message, then the passphrase twice; a hint says whether the passphrase looks weak.
  3. Press Lock it, then copy the result or save it as a .txt file.
  4. To read it later, choose Unlock text, paste the whole string, type the passphrase and press Unlock it.

A worked example

Sam locks the note “Meet at 6 pm, gate B” with the passphrase “orbit lantern cobalt meadow”.

  • The note is 20 characters of plain English, so 20 bytes. Letters with accents or symbols such as ₹ take 2 or 3 bytes each.
  • Bytes packed: 16 + 12 + 20 + 16 = 64 bytes.
  • 64 × 4 ÷ 3 = 85.3, rounded up to 86 characters of base64url, plus the 14-character prefix: 100 characters in all.

Sam presses Lock it again with the same note and passphrase. The string is completely different, because the salt and IV are new; both still unlock to the same note. Typing “meadows” instead of “meadow” fails, and so does changing one character near the end of the string: the tag no longer matches.

The four-word passphrase gets the “strong” hint because it has 4 words. Its real strength depends on the words being picked at random, not taken from a song or saying.

Checked with the tools

Everything above was run with the tool’s own code (src/lib/dev/crypt.ts) in Node 22, which has the same Web Crypto as browsers. lock() returned a 100-character string starting fibub1.600000., a second lock() gave a different string, unlock() returned the note with the right passphrase and “wrong” with “meadows” or with one changed character, and passHint() rated the passphrase strong. Key making took under a tenth of a second on our test machine; phones take longer.

Where it is used

  • Recovery codes and notes. Keep backup codes in a cloud note without the provider being able to read them.
  • Sending one secret. Send the locked string by email and the passphrase by a different route, such as a phone call.
  • Teaching. Salt, nonce and tag are the same building blocks used in messaging apps and disk encryption.
  • Printed backups. A locked string can be printed and stored, then typed back in.

Common mistakes

  • A short or famous passphrase. The rounds slow guessing, but “Summer24” is still among the first guesses. Use four or more random words.
  • Sending the passphrase with the message. If both travel together, anyone who sees one sees both.
  • Cutting the string. Missing even one character breaks it. Copy it whole.
  • Forgetting the passphrase. There is no reset. Store it somewhere safe, such as a password manager.

Questions people ask

Is AES-256 breakable? No practical attack on AES itself is known. Real failures come from weak passphrases, malware on the device, or the passphrase being shared carelessly.

Why does the same text give a different result each time? The salt and IV are random every time, so nobody can tell that two locked strings hold the same message.

What is the difference between hashing and encrypting? A hash is one-way: you can check text against it but not get the text back. Encryption is two-way with the right key.

Sources

  • AES-GCM (NIST SP 800-38D) and PBKDF2 with HMAC-SHA-256 (RFC 8018) as built into the Web Crypto API of your browser. The 600,000 rounds follow OWASP's Password Storage Cheat Sheet figure for PBKDF2-HMAC-SHA256 (checked 2026-12-05). The packing format (fibub1, salt, IV, ciphertext) is fibub's own and is described in the guide. fibub has not had this tool audited by a third party: for secrets that could cause serious harm, use well-known tools such as GnuPG or age.

If you are an author or publisher and want a credit or a passage changed or removed, tell us and we will act quickly.

Tools in this article

Read next