Visual RFC.
ALL RFCs / RFC 6238
Read the RFC ↗
RFC 6238 / TIME-BASED ONE-TIME PASSWORDS

Reduce to digits and keep leading zeros

03

A short code is a decimal string, not the whole digest. Reduce the 31-bit integer modulo 10 raised to the agreed digit count, then pad on the left with zeros to that width.

RFC 6238 · Appendix BEXAMPLE
3 / 3
Reduce to digits and keep leading zerosThe first two states apply different agreed decimal widths to the same public1094287082 intermediate integer: modulo100000000 gives the published eight-digit94287082, while modulo1000000 gives the illustrative six-digit287082. The third state is a separate published input at Unix time 1111111109: a remainder7081804 must be left-padded to07081804. The two different input times are explicitly marked; padding does not change the numerical remainder.Keep the agreed decimal widthDifferent input: Unix time 1111111109Eight-digit remainder: 7081804left-pad to eight digits07081804The leading 0 is part of the code string
03
Keep the leading zero in another published vector.

At Unix time 1111111109 the remainder is7081804, but the eight-digit string is07081804. The leftmost zero is part of the code.

Source for this drawing: RFC 6238 · Read RFC source: Appendix B ↗

Protocol participantThreat or exceptionProtocol controlSimplified drawings · precise section references
New to this? Start hereA quick picture + helpful background

A message needs an address.

Think of a packet as a small addressed envelope. Devices pass it onward; transport protocols decide what delivery promises an application gets.

Helpful first, if these ideas are unfamiliar

These pictures are analogies to help you learn. The linked RFC explains the actual rules.

Terms in this drawing
Modulo
The remainder after integer division.
Zero padding
Adding leading zeros so the decimal string has exactly the agreed number of digits.
Related RFCs and changes

“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.

KEY POINT

TOTP reuses HOTP digit reduction. The Appendix B test vectors use eight digits; this does not make eight digits a universal requirement for every deployment.

  • TOTP reuses HOTP digit reduction. The Appendix B test vectors use eight digits; this does not make eight digits a universal requirement for every deployment.
  • 1094287082 mod 100000000 = 94287082: the published eight-digit value at time 59 for HMAC-SHA-1.
  • With a separately agreed six-digit setting, the same intermediate value gives 1094287082 mod 1000000 = 287082. This is an illustration, not a six-digit Appendix B vector.
  • At time 1111111109, the published eight-digit HMAC-SHA-1 value is 07081804. Dropping the leading zero changes the representation; preserve all eight characters.
  • HOTP requires at least six digits (RFC 4226 §5.3). Both sides must agree on output width and hash choice to interoperate. Short-code collisions are possible; a new time step is not a uniqueness guarantee.
DETAILS

A decimal code is not an encryption key, signature, identity certificate or proof of which website requested it. This page is an explanation using public fixtures, not a live authenticator. No real account or secret is needed. RFC 4226 §5.3 describes modulo and digit limits; RFC 6238 Appendix B supplies the exact eight-digit expectations.

Read the RFC section ↗

All chapters in RFC 6238

Drawing view

Scroll the drawing to see every part. Playback controls stay above it.

RFC 9700 / CHAPTERS

Chapters

For full details, tables, algorithms, and exceptions, read the original RFC.

RFC status and corrections ↗