OTP Lifetime Calculator
Balance one-time-passcode length, validity window and attempt limits against the odds an attacker guesses the code.
About OTP Lifetime Calculator
A numeric OTP has almost no entropy — six digits is 19.93 bits, which an offline attacker would exhaust instantly. Its security comes entirely from the attempt limit and the validity window, so the guess probability is a binomial over a handful of tries against a million codes. Lengthening the code buys 3.32 bits per digit; tightening the attempt limit is usually the cheaper control. Without an attempt cap a six-digit code is trivially brute-forced in bulk, which is exactly how several high-profile SMS-verification bypasses worked; the maths shows how thin the margin is.
Formulas
OTP Lifetime
P(guess) = 1 − (1 − 1 ÷ 10^digits)^attempts, where attempts is the lower of the per-code limit and the rate limit over the validity window.
- 10^digits
- Number of possible codes — 1,000,000 for six digits
- attempts
- Guesses the attacker gets before the code dies or throttling stops them
Break-even attempt count
attempts for a 50 % chance = ln(0.5) ÷ ln(1 − 1 ÷ 10^digits).
Worked example
With the default values below, OTP Lifetime Calculator returns Chance an Attacker Guesses It of 0.000300%. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Passcode lengthaccepts 4–10 digits
- 6 digits
- Validity windowaccepts 10–86,400 seconds
- 300 seconds
- Attempts allowed per codeaccepts 1–100 attempts
- 3 attempts
- Rate limitaccepts 1–10,000 attempts/min
- 10 attempts/min
Results
- Chance an Attacker Guesses It
- 0.000300%
- Possible Codes
- 1,000,000 codes
- Passcode Entropy
- 19.93 bits
- Effective Attempts per Code
- 3 attempts
- Attempts for a 50 % Chance
- 693,147 attempts
Step by step
- 1Values used
- 2OTP Lifetime
- 3Break-even attempt count
- 4Chance an Attacker Guesses It= 0.000300
- 5Possible Codes= 1,000,000 codes
- 6Passcode Entropy= 19.93 bits
- 7Effective Attempts per Code= 3 attempts
- 8Attempts for a 50 % Chance= 693,147 attempts
Assumptions and limits
- The result is derived only from the 4 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to 6 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
Frequently Asked Questions
How is OTP Lifetime calculated?
P(guess) = 1 − (1 − 1 ÷ 10^digits)^attempts, where attempts is the lower of the per-code limit and the rate limit over the validity window. A numeric OTP has almost no entropy — six digits is 19.93 bits, which an offline attacker would exhaust instantly. Its security comes entirely from the attempt limit and the validity window, so the guess probability is a binomial over a handful of tries against a million codes. Lengthening the code buys 3.32 bits per digit; tightening the attempt limit is usually the cheaper control.
Why does OTP Lifetime matter?
Without an attempt cap a six-digit code is trivially brute-forced in bulk, which is exactly how several high-profile SMS-verification bypasses worked; the maths shows how thin the margin is.
What values do I need to enter?
This calculator takes 4 inputs: Passcode length, Validity window, Attempts allowed per code, Rate limit. The pre-filled defaults are a realistic starting point — replace them with figures from your own environment for a result you can act on.
How long should an OTP live?
NIST SP 800-63B allows a maximum of 10 minutes for an out-of-band secret and 2 minutes is common practice for SMS. A longer window does not weaken the code directly, but it widens the interval in which a phished code can be replayed and gives a rate-limited attacker more attempts.
Is six digits enough?
Yes, with throttling: three attempts against a million codes is a 0.0003 % chance. Without throttling the same code falls to a few hundred thousand automated attempts. The attempt limit, not the digit count, is the control that matters.
