Why the Six Digit Code in Your Authenticator App Lasts 30 Seconds

You open your phone, glance at a six digit number, type it in, and move on. The number was never saved anywhere you can see, and half a minute later it will be gone. That tiny countdown ring is one of the quietest pieces of security engineering most people use every day.

The short life of the code is deliberate. It keeps a stolen number useless almost at once, while leaving enough time for a normal person to read it and type it. Services that value a smooth sign in experience, such as the clear account area behind a sankra login, often pair a familiar password step with this kind of rotating code, so the entry feels quick on a phone yet stays well organised. For the user it means one short habit, open the app, read the digits, and continue.

How the code is actually made

Your phone and the server share one secret, a long string of characters exchanged once, usually through a QR code during setup. After that, neither side sends the secret again. Each side simply combines it with the current time and runs the same calculation.

The method is called TOTP, time based one time password, and it is described in a public standard known as RFC 6238. It builds on an older counter based scheme. Instead of a counter that goes up with each use, TOTP counts how many 30 second slices have passed since 1 January 1970. That number goes into a hashing function, and the result is trimmed down to six digits.

Element Typical value
Time step 30 seconds
Code length 6 digits
Possible codes 1,000,000
Hash function HMAC with SHA 1

 

Because both devices do the same sum, nothing has to travel between them at the moment of login. Three details make the system work in practice.

  • The secret never leaves your phone after setup.
  • No mobile signal is needed to generate a code.
  • Servers usually accept the neighbouring time slice to forgive small clock drift.

Why 30 seconds and not 10 or 120

Thirty is a compromise. A window of 10 seconds would frustrate anyone who reads the digits, switches apps and types slowly. A window of two minutes would give an attacker who has tricked you into revealing a code plenty of time to use it.

With a million possible codes, a guesser has a one in a million chance on any single try. Short windows combined with limits on failed attempts make blind guessing hopeless. The 30 second figure came from the early hardware tokens that inspired the standard, and it stuck because it fits human reading speed so well.

What happens when the clock is off

Picture a phone whose clock runs 40 seconds slow. Its codes will look perfectly valid, yet the server will reject them because it is calculating a different time slice. Most servers allow one step either side, which covers a drift of about 30 seconds.

Beyond that, you need to resync. On Android, the sync option inside the authenticator app fixes the offset. On iPhone, switching on automatic date and time in settings is usually enough. It is the most common reason a correct looking code fails, and it is quite easy to fix.

Habits that keep the codes working for you

The system is sturdy, but a few simple habits make it far more useful. Treat the setup QR code like a password, because anyone who photographs it can generate your codes. Save the backup codes the service offers and keep them offline, away from the phone they protect. If you change phones, move your accounts with the export feature of your app before wiping the old device. Some apps sync through an encrypted cloud copy, which is convenient, while others keep everything local, which is simpler to reason about.

Before retiring the old phone, log in once on the new one and confirm that every account accepts a fresh code, which takes about five minutes and saves a lot of stress. Finally, never read a code aloud to someone who contacts you first. Genuine support teams do not ask for it. The half minute lifespan protects you from old leaks, but it cannot protect you from a code you hand over willingly while the clock is still running.

Leave a Comment