Visual RFC.
ALL RFCs / RFC 4226
Read the RFC ↗
RFC 4226 / Counter-based one-time passwords

Select four bytes and reduce to digits

03

Dynamic truncation uses the low four bits of the last HMAC byte to choose four consecutive bytes.

RFC 4226 · § 5.3EXAMPLE
4 / 4
Select four bytes and reduce to digitsSame four selected bytes feed decimal modulo1000000; output872921, preserving fixed display width including zero padding.Dynamic truncation: bytes → number → digitsSeparate official §5.4 example01f18629836940e5026ca716861985105011ef127f131914da158e1694175b1855195a1357872921 mod 1000000Six-digit result: 872921Example remainder 42 displays 000042Twenty-byte SHA-1 output · no fixed-offset substitution
04
Take the decimal remainder

The result is displayed in six decimal positions. Leading zeroes are retained; truncation is not encryption or six selected digest characters.

Source for this drawing: RFC 4226 · Read RFC section 5.3 ↗

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

A seal answers a specific question.

A certificate or signature supports particular checks about a key or message. It does not automatically prove that every claim or sender is trustworthy.

Helpful first, if these ideas are unfamiliar

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

Related RFCs and changes

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

KEY POINT

Use a byte offset, clear the top bit, then take the decimal remainder.

  • HS is exactly 20 bytes for base HOTP. Its byte 19 supplies the low-order four bits as an offset in 0…15. Copy the four consecutive bytes starting at that byte offset; mask their most significant bit to obtain an unsigned31-bit integer (§5.3).
  • The official §5.4 example digest is1f8698690e02ca16618550ef7f19da8e945b555a. Its last byte5a has low nibblea, decimal 10. Select bytes=10…13:50 ef 7f 19. Clearing the high bit leaves50ef7f19, decimal1357872921.
  • With Digit=6, reduce1357872921 modulo1000000 to get 872921. Display exactly six digits, preserving leading zeroes; illustrative remainder42 is000042 (Appendix C). This §5.4 example is separate from the Appendix D key/counter vectors.
  • Implementations MUST extract at least six digits; considering seven or more is a SHOULD (§5.3). This guide illustrates six, and the bounded helper supports six through eight as explicitly discussed there. It does not impose the proposed nine-digit MUST NOT from Held for Document Update erratum 5792 as an accepted new requirement.
  • Reported errata 6756 and7651 discuss alternate digest lengths and bit/byte notation. They are not verified corrections. This guide uses the unambiguous20-byte SHA-1 example in §5.4 and byte indexes. Reported erratum 5129 proposes fixed-offset Appendix D results; retain the published dynamic-offset values.
DETAILS

Offline public test values and selected rules; not a login service, secure token implementation or deployment recommendation.

Read the RFC section ↗

All chapters in RFC 4226

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 ↗