Sometimes you have a 2FA secret key but not the phone: a new device, a shared team account, a test login. Most "online 2FA" sites solve this, but it's rarely clear whether your key is sent to their server.
So I built Get2FA, a TOTP generator that runs 100% client-side.
How it works
TOTP (RFC 6238) is simple: decode the Base32 secret, take the current 30-second counter, compute an HMAC and truncate it to 6 digits. Browsers already ship HMAC-SHA1/256/512 in the Web Crypto API, so no library is needed:
const key = await crypto.subtle.importKey('raw', secretBytes, { name: 'HMAC', hash: 'SHA-1' }, false, ['sign']); const mac = new Uint8Array(await crypto.subtle.sign('HMAC', key, counterBytes)); const o = mac[mac.length - 1] & 15; const code = (((mac[o] & 127) << 24) | (mac[o + 1] << 16) | (mac[o + 2] << 8) | mac[o + 3]) % 1e6; The whole engine is about 200 lines and is tested against the official RFC 4226 and RFC 6238 vectors.
Things I added
- Bulk mode: paste many keys, or lines like
login|password|SECRET, and copy all codes at once. - Google Authenticator export: the export QR uses
otpauth-migration://with a protobuf payload. A tiny hand-written protobuf reader turns it back into normal keys. - Private links:
get2fa.online/#KEY. The part after#is never sent to the server. - QR images: native
BarcodeDetectorwhere available, a self-hosted jsQR fallback elsewhere.
Verify it
Open DevTools, go to Network and paste a test key like JBSWY3DPEHPK3PXP. No request contains it.
The code is MIT-licensed: github.com/fernandodealmeida569-blip/get2fa. Feedback on the security model is very welcome.