Handling a Base32 secret and its QR code safely
A secret only has to be copied once. Knowing how it is written down and where it lingers narrows the ways it can leak.
The Base32 alphabet
Base32 writes bytes with 32 characters: A to Z and 2 to 7. The digits 0 and 1 and the letters I, L and O are left out so nobody confuses them.
So a 0 or a 1 inside a secret means it is not Base32, or somebody typed it by hand. Check before computing anything.
Spaces, lowercase and padding
Secrets are usually displayed in groups of four, so spaces creep in. They also get copied in lowercase, or with '=' padding at the end.
This tool strips spaces, hyphens, lowercase and trailing '=' automatically. Characters outside the alphabet, or a length that is not a valid Base32 length, are still reported.
Secret lengths
Common lengths are 80 bits (10 bytes, 16 characters), 128 bits (16 bytes, 26 characters), 160 bits (20 bytes, 32 characters) and 256 bits (32 bytes, 52 characters).
Base32 writes 5 bits per character, so 8 characters are 5 bytes. A 32-character secret is exactly 20 bytes.
The otpauth:// URI structure
The URI looks like otpauth://totp/Issuer:account?secret=...&issuer=...&algorithm=SHA1&digits=6&period=30. HOTP uses hotp instead of totp and counter instead of period.
Issuer and account are labels. The values that matter for the calculation are secret, algorithm, digits and period (or counter). This tool fills all four from the URI.
The risk in a QR code
A QR code contains the secret in plain form. A photo or a screen capture exposes it completely, and pasting the URI into an online QR service sends the secret to that service.
That is why this page draws the QR with its own JavaScript. No generation request leaves the browser.
Screen sharing and captures
Leaving this page open during remote support or a screen share shows the secret and the QR. Close the tab afterwards, and delete any capture you kept.
Browser extensions can read the page too. Disable them or use a separate profile when you handle secrets.
How to store it
Keep it in the authenticator's encrypted store or on a hardware key. If you write it on paper, keep it apart from other important documents in a locked place.
Avoid messengers, mail, cloud notes and screenshot albums. If you must back it up, use an encrypted vault and manage separately who can open it.
Revoking and re-enrolling
If a device is lost or the secret may have leaked, disable two-factor authentication in the service and enrol again to get a new secret. The old one becomes useless immediately.
Regenerate recovery codes at the same time and remove the old entry from the authenticator. After re-enrolling, paste the new secret here once to confirm the codes match.
Questions in this article
Can a secret end with '='?
Trailing padding is optional and does not change the value. This tool removes it. An '=' in the middle means the secret is malformed.
Is Base32 case-sensitive?
Uppercase is the standard, but many apps accept lowercase. This tool converts lowercase to uppercase before decoding.
Is it safe to save the QR as an image?
The image is the secret. Do not keep it in an unencrypted photo album or cloud drive, and delete it when it is no longer needed.
An example secret is already loaded. Replace it with yours and the code changes on the spot.
Open the workbench