A 2FA secret, its QR code and the current code
Two-factor authentication with a 6-digit code relies on a seed, also called the TOTP secret: a secret shared between the service and the authenticator app. From this seed and the current time, both compute the same code every 30 seconds, using the TOTP algorithm defined in RFC 6238. The generator creates this seed in your browser and gives you everything you need to use it:
- the seed: 20 random bytes (160 bits, the length recommended by RFC 4226), drawn by
crypto.getRandomValuesand written in Base32, that is 32 characters with no=padding; - the
otpauth://totp/URI, which combines the seed, the issuer, the account name and the calculation parameters; - the QR code of that URI, to scan with the app;
- the current code, computed with the Web Crypto API, to check that the app has saved the seed correctly.
When to generate your own seed
Most online services create the seed themselves and show it as a QR code when you turn 2FA on. This generator is for when you are the one who has to provide it: a developer adding TOTP to an application who needs a test seed, an administrator provisioning an account on a system that accepts a supplied seed, a trainer showing how two-factor authentication works. For a team account whose service has already provided the seed, our guide explains how to share it.
The settings
The issuer and the account are the labels the app will display, for example “Example” and “alice@example.com”. They appear in the URI, which looks like this:
otpauth://totp/Example:alice@example.com?secret=…&issuer=Example
The calculation parameters are the ones every app understands: SHA-1, 6 digits, 30 seconds. The known weaknesses of SHA-1 concern collisions and do not affect HMAC-SHA-1, on which TOTP is built: it is the most compatible setting, without being a weak spot. Other values exist, but not every app supports them.
Check with the current code
Scan the QR code with the app, or enter the seed manually: every authenticator app allows it. Then compare the app's code with the one on the page. They must match. The page's code is computed from your computer's clock, the app's code from your phone's clock: if either device has the wrong time, the codes differ. Turn on automatic time setting, then compare again.
Share a seed the way you would share a password
Whoever holds the seed can generate codes at will, for as long as two-factor authentication stays set up with it. It is therefore an access credential, just like the account password, and should not sit in plain text in an email or a shared document.
“Send with onlyU” sends the seed, grouped in blocks of 4 characters, with its parameters (“TOTP, 6 digits, 30 s”), ready to be entered into an app. onlyU encrypts it in your browser and creates a link your recipient can open only once, valid for 24 hours, after which the link disappears. For an account used by several people, read our guide on how to share 2FA access to a shared account.