# TOTP / OTP Generator

> Generate live 6-digit TOTP codes from a Base32 secret key with a 30-second countdown, plus the previous and next codes. RFC 6238, runs in your browser.

- Page: https://mondaytool.com/tools/totp-generator
- Category: security
- Price: free, no sign-up. Most tools run in the browser, so input is not uploaded.
- Use it: open https://mondaytool.com/tools/totp-generator. It is an interactive web page; this file is its documentation.

Last updated: 14 October 2026

## Generate TOTP codes from a secret key

This **TOTP generator** creates 6-digit, time-based one-time passwords from a Base32 secret key. It shows the current code with a 30-second countdown, plus the previous and next codes. It is made for testing two-factor login (2FA) while you build or debug an app.

## How to use it

1. Enter your **Secret Key (Base32)**. A sample key, `JBSWY3DPEHPK3PXP`, is filled in so you can try it right away.
2. Read the **Current Code**. The bar and the seconds counter show how long it stays valid.
3. Click **Copy** to copy the current code.
4. Compare it with the **Previous (−30s)** and **Next (+30s)** codes if your server allows a time window.

## How it works

The tool follows **RFC 6238** with fixed settings: HMAC-SHA1, a 30-second period and 6 digits.

1. The secret is decoded from Base32. Spaces and trailing `=` padding are ignored, and lowercase letters are turned into capitals.
2. The time step is the current Unix time divided by 30, rounded down.
3. The step is written as 8 bytes and signed with HMAC-SHA1 using the decoded key.
4. Dynamic truncation picks 4 bytes from the signature. The number is taken modulo 1,000,000 and padded to 6 digits.

The HMAC is done with your browser's Web Crypto API (SubtleCrypto). The secret and codes are not sent to a server.

## Tips

- Use test secrets only. Never paste a real production secret into any web tool.
- Codes depend on your device clock. If they do not match your app, check that the clock is set correctly.
- Only the letters A–Z and digits 2–7 are valid Base32. Any other character shows an error.
- The period, digit count and algorithm cannot be changed. Keys set up for 8 digits, 60 seconds or SHA-256 will not match.

## Frequently asked questions

### Will these codes match Google Authenticator?

Yes, for standard keys that use SHA-1, 6 digits and 30 seconds, which is the usual default. The clocks on both devices also need to be correct.

### Why do I see an "Invalid Base32 character" error?

The key contains a character outside A–Z and 2–7, such as 0, 1, 8 or 9. Check that you copied the full secret correctly.

### Why does it show the previous and next codes?

Many servers accept a code from one step before or after the current one to allow for clock drift. Seeing all three helps you debug a login check.
