# \[Crypto\] Time-based one-time password (TOTP) for 2FA, part I

DevFeed: [\[Crypto\] Time-based one-time password (TOTP) for 2FA, part I](<https://devfeed.tech/articles/crypto-time-based-one-time-password-totp-for-2fa-part-i-20550.md>)

Original publisher: [Read original article](<https://yurichev.com/blog/TOTP1/>)

Published: 2026-09-09T22:00:00Z

Content type: tutorial

Language: en

Sources: [Dennis Yurichev](<https://devfeed.tech/sources/dennis-yurichev.md>)

Topics: [passwords](<https://devfeed.tech/topics/passwords.md>), [QR Code](<https://devfeed.tech/topics/qrcode.md>), [Google](<https://devfeed.tech/topics/google.md>), [Python](<https://devfeed.tech/topics/python.md>), [Unix](<https://devfeed.tech/topics/unix.md>), [App](<https://devfeed.tech/topics/app.md>), [email](<https://devfeed.tech/topics/email.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [account](<https://devfeed.tech/tags/account.md>), [app](<https://devfeed.tech/tags/app.md>), [argument](<https://devfeed.tech/tags/argument.md>), [backup](<https://devfeed.tech/tags/backup.md>), [code](<https://devfeed.tech/tags/code.md>), [crypto](<https://devfeed.tech/tags/crypto.md>), [env-file-security](<https://devfeed.tech/tags/env-file-security.md>), [github](<https://devfeed.tech/tags/github.md>), [google](<https://devfeed.tech/tags/google.md>), [password](<https://devfeed.tech/tags/password.md>), [protection](<https://devfeed.tech/tags/protection.md>), [python](<https://devfeed.tech/tags/python.md>), [run](<https://devfeed.tech/tags/run.md>), [server](<https://devfeed.tech/tags/server.md>), [smartphone](<https://devfeed.tech/tags/smartphone.md>), [unix](<https://devfeed.tech/tags/unix.md>)

## AI overview

This tutorial explains how time-based one-time passwords work for two-factor authentication. It covers importing a base32-encoded secret from a QR code into Google Authenticator, generating 6-digit login codes, and calculating them with HMAC-SHA-1 from the secret and Unix time. It also discusses backup codes and securely storing TOTP secrets separately from passwords.

## Source excerpt

[Crypto] Time-based one-time password (TOTP) for 2FA, part I