• About TC
  • Affiliate Disclaimer
  • Privacy Policy
  • TOS
  • Contact
Sunday, July 6, 2025
Techcratic
  • TC
  • AI
    Artificial Intelligence

    Transforming network operations with AI: How Swisscom built a network assistant using Amazon Bedrock

    Artificial Intelligence

    EgoDex: Learning Dexterous Manipulation from Large-Scale Egocentric Video

    Artificial Intelligence

    Instruction-Following Pruning for Large Language Models

    Artificial Intelligence

    How to Combine Streamlit, Pandas, and Plotly for Interactive Data Apps

    Artificial Intelligence

    Tailor responsible AI with new safeguard tiers in Amazon Bedrock Guardrails

    Artificial Intelligence

    Automate Data Quality Reports with n8n: From CSV to Professional Analysis

    Artificial Intelligence

    NewDay builds A Generative AI based Customer service Agent Assist with over 90% accuracy

    Artificial Intelligence

    5 Things You Need to Know About Agentic AI

    Artificial Intelligence

    Normalizing Flows are Capable Generative Models

  • App Zone
    Top 3 Launcher Apps for Apple: Features, Pros, and Cons

    Top 3 Launcher Apps for Apple: Features, Pros, and Cons

    Top 3 Launcher Apps for Android: Features, Pros, and Cons

    Top 3 Launcher Apps for Android: Features, Pros, and Cons

    Top 3 Card Game Apps of 2025: Features, Pros, and Cons

    Top 3 Card Game Apps of 2025: Features, Pros, and Cons

    Top 3 Medical Apps of 2025: Features, Pros, and Cons

    Top 3 Medical Apps of 2025: Features, Pros, and Cons

    Top 3 Travel Apps of 2025: Features, Pros, and Cons

    Top 3 Travel Apps of 2025: Features, Pros, and Cons

    Top 3 Casual Game Apps for 2025: Features, Pros, and Cons

    Top 3 Casual Game Apps for 2025: Features, Pros, and Cons

    Top 3 Food Apps for 2025: Features, Pros, and Cons

    Top 3 Food Apps for 2025: Features, Pros, and Cons

    Top 3 Sport Apps for 2025: Features, Pros, and Cons

    Top 3 Sport Apps for 2025: Features, Pros, and Cons

    Top 3 Productivity Apps for 2025: Features, Pros, and Cons

    Top 3 Productivity Apps for 2025: Features, Pros, and Cons

  • Apple
    Yes, you can run Windows 11 on your Mac — and it’s only $15

    Run Windows apps on your Mac with Windows 11 Pro — now just $9.97

    How to stop LG & Samsung smart TV tracking, screen captures

    How to stop LG & Samsung smart TV tracking, screen captures

    Apple’s F1 expected to hit $300M at the box office this weekend

    Apple’s F1 expected to hit $300M at the box office this weekend

    Apple is reportedly working on a cheaper MacBook, but will it stick the landing?

    Apple is reportedly working on a cheaper MacBook, but will it stick the landing?

    Apple @ Work: Macs have never been more expensive to repair, but never been more reliable

    Apple @ Work: Macs have never been more expensive to repair, but never been more reliable

    New Gemini icon comes to Android and iPhone

    New Gemini icon comes to Android and iPhone

    Best Mac SSD and hard drive Prime Day deals 2025: Early discounts

    Best Mac SSD and hard drive Prime Day deals 2025: Early discounts

    This is the letter Donald Trump sent Apple to keep TikTok online

    This is the letter Donald Trump sent Apple to keep TikTok online

    Siri’s future, the original iPhone’s past, and Apple Music’s birthday

    Siri’s future, the original iPhone’s past, and Apple Music’s birthday

  • Retro Rewind
    Retro Rewind: Electronic Games April 1995

    Retro Rewind: Electronic Games April 1995

    Retro Rewind: Electronic Gaming Monthly Magazine Number 55 February 1994

    Retro Rewind: Electronic Gaming Monthly Magazine Number 57 April 1994

    Retro Rewind: Blast from the Past – 35 Iconic Commercials of 1988!

    Retro Rewind: Blast from the Past – 35 Iconic Commercials of 1988!

    Retro Rewind: PC World Magazine August 1998

    Retro Rewind: PC World Magazine August 1998

    Retro Rewind: Computer Shopper Magazine September 1997

    Retro Rewind: Computer Shopper Magazine September 1997

    Retro Rewind: PC Magazine December 2015

    Retro Rewind: PC Magazine December 2015

    Retro Rewind: EDGE Magazine RETRO #1: The Guide to Classic Videogame Playing and Collecting

    Retro Rewind: EDGE Magazine RETRO #1: The Guide to Classic Videogame Playing and Collecting

    Retro Rewind: Computer Gaming World Magazine Issue 73 December 1998

    Retro Rewind: Computer Gaming World Magazine Issue 73 December 1998

    Retro Rewind: Electronic Gaming Monthly Magazine Number 55 February 1994

    Retro Rewind: Electronic Gaming Monthly Magazine Number 55 February 1994

  • Tech Deals
    CableCreation 6 Feet TRRS Headhpone Extension Cable Bundle with 1.5 Feet TRRS…

    CableCreation 6 Feet TRRS Headhpone Extension Cable Bundle with 1.5 Feet TRRS…

    ASRock Chanllenger AMD RX 6600 8G GDDR6 Graphics Card and Bronze 80+ 550W Power Supply

    ASRock Chanllenger AMD RX 6600 8G GDDR6 Graphics Card and Bronze 80+ 550W Power Supply

    INNOCN 49″ Curved Gaming Monitor 144Hz Ultrawide 32:9 WDFHD 3840 x 1080P, R1800, 99%…

    INNOCN 49″ Curved Gaming Monitor 144Hz Ultrawide 32:9 WDFHD 3840 x 1080P, R1800, 99%…

    Razer Iskur V2 Gaming Chair: Adaptive Lumbar Support – Adjustable Lumbar Curve – High…

    Razer Iskur V2 Gaming Chair: Adaptive Lumbar Support – Adjustable Lumbar Curve – High…

    Critical Rolls: Boxed Set – 5e RPG Storytelling Cards, 300 Tarot Sized Cards, Tabletop…

    Critical Rolls: Boxed Set – 5e RPG Storytelling Cards, 300 Tarot Sized Cards, Tabletop…

    Nintendogs Dachshund & Friends (Renewed)

    Nintendogs Dachshund & Friends (Renewed)

    Gamer [Blu-ray]

    Gamer [Blu-ray]

    Transcend TS-RDF2 Cfast 2.0 USB 3.1 Card Reader

    Transcend TS-RDF2 Cfast 2.0 USB 3.1 Card Reader

    MaxLLTo USB 3.0 Power Charger Data SYNC Cable Cord for Toshiba External Hard Drive Disk…

    MaxLLTo USB 3.0 Power Charger Data SYNC Cable Cord for Toshiba External Hard Drive Disk…

  • Tech Eats
    Cheesy Broccoli Rice Mug: 5-Minute Super Comfort Food

    Cheesy Broccoli Rice Mug: 5-Minute Super Comfort Food

    Top 10 Vegetarian Recipes for 2025: Easy and Nutritious Meals for Busy People

    Top 10 Vegetarian Recipes for 2025: Easy and Nutritious Meals for Busy People

    Bacon Mug Lasagna: 5-Minute Microwave Meat Lover’s Dream

    Bacon Mug Lasagna: 5-Minute Microwave Meat Lover’s Dream

    Bacon Fried Rice Mug: 5-Minute Microwave Meal

    Bacon Fried Rice Mug: 5-Minute Microwave Meal

    Bacon & Cheddar Mug Biscuit: 2-Minute Savory Comfort

    Bacon & Cheddar Mug Biscuit: 2-Minute Savory Comfort

    Loaded Bacon Cheesy Potato Mug: 5-Minute Comfort Food

    Loaded Bacon Cheesy Potato Mug: 5-Minute Comfort Food

    Peanut Butter Banana Mug Muffin: 5-Minute Protein Snack

    Peanut Butter Banana Mug Muffin: 5-Minute Protein Snack

    Oreo Mug Cake: 2-Minute Cookie & Cake Combo!

    Oreo Mug Cake: 2-Minute Cookie & Cake Combo!

    Tiramisu Mug Cake: Coffee Lover’s Dream in 2 Minutes!

    Tiramisu Mug Cake: Coffee Lover’s Dream in 2 Minutes!

  • Tesla
    Tesla Supercharger to CCS1 Charger Adapter, Max 500A 1000V NACS to CCS EV Fast Charge…

    Tesla Supercharger to CCS1 Charger Adapter, Max 500A 1000V NACS to CCS EV Fast Charge…

    BestEvMod for Refreshed Model 3 Highland Cargo Liner Floor Liners Trunk and Frunk Mat…

    BestEvMod for Refreshed Model 3 Highland Cargo Liner Floor Liners Trunk and Frunk Mat…

    4 PCS Car Front and Rear Side Window Sunshade, 19.6″ x 31.4″ x 7.8″ + 19.6″ x 31.4″ Keep…

    4 PCS Car Front and Rear Side Window Sunshade, 19.6″ x 31.4″ x 7.8″ + 19.6″ x 31.4″ Keep…

    Car Floor Mats for Tesla Cybertruck 2023 2024 2025, Custom TPE All Weather Protection…

    Car Floor Mats for Tesla Cybertruck 2023 2024 2025, Custom TPE All Weather Protection…

    JOYTUTUS Truck Bed Divider Compatible with Cybertruck 2024 2023 Cargo Divider Organizer…

    JOYTUTUS Truck Bed Divider Compatible with Cybertruck 2024 2023 Cargo Divider Organizer…

    HANSSHOW Pet Seat Covers for Cybertruck Rear Dog Seat Protector Full-Cover Waterproof…

    HANSSHOW Pet Seat Covers for Cybertruck Rear Dog Seat Protector Full-Cover Waterproof…

    Center Console Organizer Tray Compatible with Tesla Cybertruck 2024 2025 Accessories,…

    Center Console Organizer Tray Compatible with Tesla Cybertruck 2024 2025 Accessories,…

    Cybertruck Sticker Vinyl Bumper Sticker Decal Waterproof 5″

    Cybertruck Sticker Vinyl Bumper Sticker Decal Waterproof 5″

    JOMISE Dash Cam Front and Rear, 4k FHD Dual Car Camera, 3″ IPS Dash Camera for Cars with…

    JOMISE Dash Cam Front and Rear, 4k FHD Dual Car Camera, 3″ IPS Dash Camera for Cars with…

  • UFO
    ERIN MONTGOMERY –  Dirty Little Secret: Confessions of an Alien Contactee

    ERIN MONTGOMERY – Dirty Little Secret: Confessions of an Alien Contactee

    Miniature Schnauzer Funny Graphic Selfie UFOs Weird Aliens T-Shirt

    Miniature Schnauzer Funny Graphic Selfie UFOs Weird Aliens T-Shirt

    Lorine Chia – Intergalactic Love (Official Music Video)

    Lorine Chia – Intergalactic Love (Official Music Video)

    John Deere Men’s Trademark Logo Core Short Sleeve Tee

    John Deere Men’s Trademark Logo Core Short Sleeve Tee

    SOJOS Retro Polarized Square Sunglasses Womens Men Vintage Double Bridge Metal Frame UV Protection Sun Glasses SJ1246

    SOJOS Retro Polarized Square Sunglasses Womens Men Vintage Double Bridge Metal Frame UV Protection Sun Glasses SJ1246

    Bill Nye on Space Exploration #billnye #science #space #spaceexploration  #masterclass

    Bill Nye on Space Exploration #billnye #science #space #spaceexploration #masterclass

    Nessie and UFO, Sasquatch Rare Selfie, The Loch Ness Bigfoot T-Shirt

    Nessie and UFO, Sasquatch Rare Selfie, The Loch Ness Bigfoot T-Shirt

    Spirit Communication by Rev. Gaurav Tiwari | Indian Paranormal Society

    Spirit Communication by Rev. Gaurav Tiwari | Indian Paranormal Society

    Crumbl Conspiracy Investigation

    Crumbl Conspiracy Investigation

No Result
View All Result
  • TC
  • AI
    Artificial Intelligence

    Transforming network operations with AI: How Swisscom built a network assistant using Amazon Bedrock

    Artificial Intelligence

    EgoDex: Learning Dexterous Manipulation from Large-Scale Egocentric Video

    Artificial Intelligence

    Instruction-Following Pruning for Large Language Models

    Artificial Intelligence

    How to Combine Streamlit, Pandas, and Plotly for Interactive Data Apps

    Artificial Intelligence

    Tailor responsible AI with new safeguard tiers in Amazon Bedrock Guardrails

    Artificial Intelligence

    Automate Data Quality Reports with n8n: From CSV to Professional Analysis

    Artificial Intelligence

    NewDay builds A Generative AI based Customer service Agent Assist with over 90% accuracy

    Artificial Intelligence

    5 Things You Need to Know About Agentic AI

    Artificial Intelligence

    Normalizing Flows are Capable Generative Models

  • App Zone
    Top 3 Launcher Apps for Apple: Features, Pros, and Cons

    Top 3 Launcher Apps for Apple: Features, Pros, and Cons

    Top 3 Launcher Apps for Android: Features, Pros, and Cons

    Top 3 Launcher Apps for Android: Features, Pros, and Cons

    Top 3 Card Game Apps of 2025: Features, Pros, and Cons

    Top 3 Card Game Apps of 2025: Features, Pros, and Cons

    Top 3 Medical Apps of 2025: Features, Pros, and Cons

    Top 3 Medical Apps of 2025: Features, Pros, and Cons

    Top 3 Travel Apps of 2025: Features, Pros, and Cons

    Top 3 Travel Apps of 2025: Features, Pros, and Cons

    Top 3 Casual Game Apps for 2025: Features, Pros, and Cons

    Top 3 Casual Game Apps for 2025: Features, Pros, and Cons

    Top 3 Food Apps for 2025: Features, Pros, and Cons

    Top 3 Food Apps for 2025: Features, Pros, and Cons

    Top 3 Sport Apps for 2025: Features, Pros, and Cons

    Top 3 Sport Apps for 2025: Features, Pros, and Cons

    Top 3 Productivity Apps for 2025: Features, Pros, and Cons

    Top 3 Productivity Apps for 2025: Features, Pros, and Cons

  • Apple
    Yes, you can run Windows 11 on your Mac — and it’s only $15

    Run Windows apps on your Mac with Windows 11 Pro — now just $9.97

    How to stop LG & Samsung smart TV tracking, screen captures

    How to stop LG & Samsung smart TV tracking, screen captures

    Apple’s F1 expected to hit $300M at the box office this weekend

    Apple’s F1 expected to hit $300M at the box office this weekend

    Apple is reportedly working on a cheaper MacBook, but will it stick the landing?

    Apple is reportedly working on a cheaper MacBook, but will it stick the landing?

    Apple @ Work: Macs have never been more expensive to repair, but never been more reliable

    Apple @ Work: Macs have never been more expensive to repair, but never been more reliable

    New Gemini icon comes to Android and iPhone

    New Gemini icon comes to Android and iPhone

    Best Mac SSD and hard drive Prime Day deals 2025: Early discounts

    Best Mac SSD and hard drive Prime Day deals 2025: Early discounts

    This is the letter Donald Trump sent Apple to keep TikTok online

    This is the letter Donald Trump sent Apple to keep TikTok online

    Siri’s future, the original iPhone’s past, and Apple Music’s birthday

    Siri’s future, the original iPhone’s past, and Apple Music’s birthday

  • Retro Rewind
    Retro Rewind: Electronic Games April 1995

    Retro Rewind: Electronic Games April 1995

    Retro Rewind: Electronic Gaming Monthly Magazine Number 55 February 1994

    Retro Rewind: Electronic Gaming Monthly Magazine Number 57 April 1994

    Retro Rewind: Blast from the Past – 35 Iconic Commercials of 1988!

    Retro Rewind: Blast from the Past – 35 Iconic Commercials of 1988!

    Retro Rewind: PC World Magazine August 1998

    Retro Rewind: PC World Magazine August 1998

    Retro Rewind: Computer Shopper Magazine September 1997

    Retro Rewind: Computer Shopper Magazine September 1997

    Retro Rewind: PC Magazine December 2015

    Retro Rewind: PC Magazine December 2015

    Retro Rewind: EDGE Magazine RETRO #1: The Guide to Classic Videogame Playing and Collecting

    Retro Rewind: EDGE Magazine RETRO #1: The Guide to Classic Videogame Playing and Collecting

    Retro Rewind: Computer Gaming World Magazine Issue 73 December 1998

    Retro Rewind: Computer Gaming World Magazine Issue 73 December 1998

    Retro Rewind: Electronic Gaming Monthly Magazine Number 55 February 1994

    Retro Rewind: Electronic Gaming Monthly Magazine Number 55 February 1994

  • Tech Deals
    CableCreation 6 Feet TRRS Headhpone Extension Cable Bundle with 1.5 Feet TRRS…

    CableCreation 6 Feet TRRS Headhpone Extension Cable Bundle with 1.5 Feet TRRS…

    ASRock Chanllenger AMD RX 6600 8G GDDR6 Graphics Card and Bronze 80+ 550W Power Supply

    ASRock Chanllenger AMD RX 6600 8G GDDR6 Graphics Card and Bronze 80+ 550W Power Supply

    INNOCN 49″ Curved Gaming Monitor 144Hz Ultrawide 32:9 WDFHD 3840 x 1080P, R1800, 99%…

    INNOCN 49″ Curved Gaming Monitor 144Hz Ultrawide 32:9 WDFHD 3840 x 1080P, R1800, 99%…

    Razer Iskur V2 Gaming Chair: Adaptive Lumbar Support – Adjustable Lumbar Curve – High…

    Razer Iskur V2 Gaming Chair: Adaptive Lumbar Support – Adjustable Lumbar Curve – High…

    Critical Rolls: Boxed Set – 5e RPG Storytelling Cards, 300 Tarot Sized Cards, Tabletop…

    Critical Rolls: Boxed Set – 5e RPG Storytelling Cards, 300 Tarot Sized Cards, Tabletop…

    Nintendogs Dachshund & Friends (Renewed)

    Nintendogs Dachshund & Friends (Renewed)

    Gamer [Blu-ray]

    Gamer [Blu-ray]

    Transcend TS-RDF2 Cfast 2.0 USB 3.1 Card Reader

    Transcend TS-RDF2 Cfast 2.0 USB 3.1 Card Reader

    MaxLLTo USB 3.0 Power Charger Data SYNC Cable Cord for Toshiba External Hard Drive Disk…

    MaxLLTo USB 3.0 Power Charger Data SYNC Cable Cord for Toshiba External Hard Drive Disk…

  • Tech Eats
    Cheesy Broccoli Rice Mug: 5-Minute Super Comfort Food

    Cheesy Broccoli Rice Mug: 5-Minute Super Comfort Food

    Top 10 Vegetarian Recipes for 2025: Easy and Nutritious Meals for Busy People

    Top 10 Vegetarian Recipes for 2025: Easy and Nutritious Meals for Busy People

    Bacon Mug Lasagna: 5-Minute Microwave Meat Lover’s Dream

    Bacon Mug Lasagna: 5-Minute Microwave Meat Lover’s Dream

    Bacon Fried Rice Mug: 5-Minute Microwave Meal

    Bacon Fried Rice Mug: 5-Minute Microwave Meal

    Bacon & Cheddar Mug Biscuit: 2-Minute Savory Comfort

    Bacon & Cheddar Mug Biscuit: 2-Minute Savory Comfort

    Loaded Bacon Cheesy Potato Mug: 5-Minute Comfort Food

    Loaded Bacon Cheesy Potato Mug: 5-Minute Comfort Food

    Peanut Butter Banana Mug Muffin: 5-Minute Protein Snack

    Peanut Butter Banana Mug Muffin: 5-Minute Protein Snack

    Oreo Mug Cake: 2-Minute Cookie & Cake Combo!

    Oreo Mug Cake: 2-Minute Cookie & Cake Combo!

    Tiramisu Mug Cake: Coffee Lover’s Dream in 2 Minutes!

    Tiramisu Mug Cake: Coffee Lover’s Dream in 2 Minutes!

  • Tesla
    Tesla Supercharger to CCS1 Charger Adapter, Max 500A 1000V NACS to CCS EV Fast Charge…

    Tesla Supercharger to CCS1 Charger Adapter, Max 500A 1000V NACS to CCS EV Fast Charge…

    BestEvMod for Refreshed Model 3 Highland Cargo Liner Floor Liners Trunk and Frunk Mat…

    BestEvMod for Refreshed Model 3 Highland Cargo Liner Floor Liners Trunk and Frunk Mat…

    4 PCS Car Front and Rear Side Window Sunshade, 19.6″ x 31.4″ x 7.8″ + 19.6″ x 31.4″ Keep…

    4 PCS Car Front and Rear Side Window Sunshade, 19.6″ x 31.4″ x 7.8″ + 19.6″ x 31.4″ Keep…

    Car Floor Mats for Tesla Cybertruck 2023 2024 2025, Custom TPE All Weather Protection…

    Car Floor Mats for Tesla Cybertruck 2023 2024 2025, Custom TPE All Weather Protection…

    JOYTUTUS Truck Bed Divider Compatible with Cybertruck 2024 2023 Cargo Divider Organizer…

    JOYTUTUS Truck Bed Divider Compatible with Cybertruck 2024 2023 Cargo Divider Organizer…

    HANSSHOW Pet Seat Covers for Cybertruck Rear Dog Seat Protector Full-Cover Waterproof…

    HANSSHOW Pet Seat Covers for Cybertruck Rear Dog Seat Protector Full-Cover Waterproof…

    Center Console Organizer Tray Compatible with Tesla Cybertruck 2024 2025 Accessories,…

    Center Console Organizer Tray Compatible with Tesla Cybertruck 2024 2025 Accessories,…

    Cybertruck Sticker Vinyl Bumper Sticker Decal Waterproof 5″

    Cybertruck Sticker Vinyl Bumper Sticker Decal Waterproof 5″

    JOMISE Dash Cam Front and Rear, 4k FHD Dual Car Camera, 3″ IPS Dash Camera for Cars with…

    JOMISE Dash Cam Front and Rear, 4k FHD Dual Car Camera, 3″ IPS Dash Camera for Cars with…

  • UFO
    ERIN MONTGOMERY –  Dirty Little Secret: Confessions of an Alien Contactee

    ERIN MONTGOMERY – Dirty Little Secret: Confessions of an Alien Contactee

    Miniature Schnauzer Funny Graphic Selfie UFOs Weird Aliens T-Shirt

    Miniature Schnauzer Funny Graphic Selfie UFOs Weird Aliens T-Shirt

    Lorine Chia – Intergalactic Love (Official Music Video)

    Lorine Chia – Intergalactic Love (Official Music Video)

    John Deere Men’s Trademark Logo Core Short Sleeve Tee

    John Deere Men’s Trademark Logo Core Short Sleeve Tee

    SOJOS Retro Polarized Square Sunglasses Womens Men Vintage Double Bridge Metal Frame UV Protection Sun Glasses SJ1246

    SOJOS Retro Polarized Square Sunglasses Womens Men Vintage Double Bridge Metal Frame UV Protection Sun Glasses SJ1246

    Bill Nye on Space Exploration #billnye #science #space #spaceexploration  #masterclass

    Bill Nye on Space Exploration #billnye #science #space #spaceexploration #masterclass

    Nessie and UFO, Sasquatch Rare Selfie, The Loch Ness Bigfoot T-Shirt

    Nessie and UFO, Sasquatch Rare Selfie, The Loch Ness Bigfoot T-Shirt

    Spirit Communication by Rev. Gaurav Tiwari | Indian Paranormal Society

    Spirit Communication by Rev. Gaurav Tiwari | Indian Paranormal Society

    Crumbl Conspiracy Investigation

    Crumbl Conspiracy Investigation

No Result
View All Result
Techcratic
No Result
View All Result
Home Hacker News

Building HOTP and TOTP from scratch

Hacker News by Hacker News
April 14, 2025
in Hacker News
Reading Time: 9 mins read
122
A A
0

2025-04-11 09:06:00
blog.dogac.dev

A while ago, I have started working on authorization and authentication at work. This taught me a lot about how modern authentication systems work. However I have always thought One-Time Password logins are the most mystical ones. A six-digit code that changes every time and can be used to verify your identity. How does the server know the newly generated one, and how is it really secure? In this post, I will explain what HOTP, TOTP is and how they work by sharing my own implementation from scratch.

A sample OTP login code

One-Time Passwords (OTPs) are a widely-used form of authentication. You’ve likely encountered them when using a “Secure Login” app like Google Authenticator, or during a “Forgot Password” flow where a temporary code is sent to your email or phone.

Unlike traditional passwords, OTPs are only valid for a single use or a limited time window. This greatly reduces the risk of password replay attacks, where someone captures the password used to login and tries to reuse it.

Passwords can be used repeatedly. When leaked, malicious actors can impersonate the user and access critical information.

Like the traditional password authentication approach, the user and the authority (server) still needs to agree on a common secret key. During the regular password authentication, this secret key is directly communicated to the authority. There are many ways of doing this process safely, such as hashing the password or sending it over an encrypted network. However the risk still exists, as the password itself never changes, as long as we use our devices to type our passwords, there is some way those malicious actors can watch and get that information before it reaching the network.

So instead of using a constant secret key, we can use something dynamic that changes over time. As a simple example, assume when those two people first met, they have set their secretly hidden clocks to a random time together.

Using secret clocks as a basic OTP implementation

Also in some examples like Facebook’s password recovery, this secret clock is not shared with the user directly but rather server’s generated one-time password is sent via a trusted medium, such as an email to the user.

Obviously a clock on its own is not secure, as in this example Plankton could have predicted the time-shift of the secret clock based on the real time. However for the sake of this example, I wanted to show how copying the “password” is not enough on its own. Let’s take a look at some strategies to build this “secret clock” and make sure it is not possible to predict time just by knowing a single code in some point in time.

There are two common types of OTP algorithms:

  • HOTP (HMAC-based One-Time Password) – based on a counter that increments every time an OTP is requested.
  • TOTP (Time-based One-Time Password) – based on the current time, typically using 30-second intervals.

These methods are standardized in RFC 4226 (for HOTP) and RFC 6238 (for TOTP), and are used in many modern 2FA (two-factor authentication) implementations.

A counter based password method is easier to understand. Imagine two people met and generated a totally random series of numbers. They both start from count 0, as in each attempt, user needs to communicate to the server with the secret key in the given index. However this comes with several problems,

  1. Clients needs to sync their counter, if there is a skew, they might get temporarily locked out.
  2. Malicious actors can collect upcoming login codes by phishing the user and those codes can be used for a long time.

Therefore, instead of storing a counter, we can use the current time as the counter. That’s how TOTP works. Using time makes synchronization easier, as many modern machines already use technologies such as NTP to sync their time and this prevents malicious actors from harvesting codes as their code will be valid for only next 30 seconds or so, not for a long sequence of future login attempts.

The analogy of two people met and decided on a totally random series of numbers is partially realistic. However it is not feasible to have such a huge list, you potentially need to have millions of secret numbers to support OTPs for a reasonable time. Therefore we should use algorithms that are cryptographically safe that generate values based on a secret key. It is important that this algorithm is not random, as both user and the authority will hold a copy of this secret key and they should be able to generate the same value given the same time.

We have introduced HOTP first because the actual implementation of TOTPs are actually HOTP based. Instead of using a static counter, TOTPs use the time as the current counter. We can write the following formula to find the counter in any given time,

\[ c(t) = \left\lfloor \frac{t – t_0}{X} \right\rfloor \]

Here \(t_0\) is the starting time, in most systems this is the default UNIX epoch timestamp, 1 January 1970. \(X\) is the period you want the code to rotate. For example, if you want the login code to change every 30 seconds, X should be 30 seconds.

In order to generate an HOTP, you need to decide on three things:

  1. A secret key
  2. A hash function
  3. Number of digits you will output

First, we need to start by hashing our secret key. For example, if we have chosen SHA-1 as our hashing algorithm, our output would be only 64 bytes. If secret key is shorted than 64 bytes, we can just pad it with zeroes. Otherwise, given \(K\) is our secret key and \(H\) is our hashing algorithm,

\[ K_{pad} = H(K) \]

Later we do an XOR operation on text with some pre-defined magic constants \(I_{pad}\) and \(O_{pad}\).

\[ I_{pad} = [\texttt{0x36}, \dots] \newline O_{pad} = [\texttt{0x5c}, \dots] \]

Those numbers are originally chosen by HMAC designers and any pair where \(I_{pad} \neq O_{pad}\) could have been chosen. Their lenght should be also 64 bytes, same as our hashing algorithm’s digest length. Later we define the famous \( \text{HMAC} \), Hash-based Message Authentication Code, function. It outputs a crypthographic hash calculated using the given key and message.

\[ \text{HMAC}(K, M) = H(K_{pad} \oplus O_{pad} + H(K_{pad} \oplus I_{pad} + M)) \]

This cryptographic hash function is secure, so that user can’t infer the secret key \( K_{pad} \) even if they knew \( M \) and the resulting hash.

Later we will define a new function to generate a 4-byte result. Here is the definition of DT from the original RFC,

    DT(String) // String = String[0]...String[19]
     Let OffsetBits be the low-order 4 bits of String[19]
     Offset = StToNum(OffsetBits) // 0 

This function allows us to shrink our 20 byte input to 4 bytes dynamically by choosing the bytes offsetted by the number that is represented using the last 4 bits of the input. The outputs of the DT on distinct counter inputs are uniformly and independently distributed.

Finally, we can define our HOTP function as,

\[ \text{HOTP}(K,C) = \text{DT}(\text{HMAC}(K,C)) \bmod 10^{\text{digits}} \]

Here we can replace our counter \( C \) with \( c(t) \) to get a TOTP code.

There are many online resources with TOTP and HOTPs, however I have struggled to find a website that help me check my implementation as their secret-key representations were not standardized. Thus, I have published my own short demo app to showcase.

OTP Generator

Test and validate OTP workflows such as TOTP and HOTP.

I have published this app on my website and also on GitHub, the implementation uses Kotlin.

To recap: We’ve looked at how HOTP and TOTP work, explored how they’re derived from HMAC, and saw how the server and client can generate matching codes without ever transmitting the password itself.

Working on this project helped me understand how OTPs work at a much deeper level. What once felt like magic now feels like elegant design.

Source Link


Keep your files stored safely and securely with the SanDisk 2TB Extreme Portable SSD. With over 69,505 ratings and an impressive 4.6 out of 5 stars, this product has been purchased over 8K+ times in the past month. At only $129.99, this Amazon’s Choice product is a must-have for secure file storage.

Help keep private content private with the included password protection featuring 256-bit AES hardware encryption. Order now for just $129.99 on Amazon!


Start your free Amazon Prime trial
today and unlock unlimited streaming and more!

Help Power Techcratic’s Future – Scan To Support

If Techcratic’s content and insights have helped you, consider giving back by supporting the platform with crypto. Every contribution makes a difference, whether it’s for high-quality content, server maintenance, or future updates. Techcratic is constantly evolving, and your support helps drive that progress.

As a solo operator who wears all the hats, creating content, managing the tech, and running the site, your support allows me to stay focused on delivering valuable resources. Your support keeps everything running smoothly and enables me to continue creating the content you love. I’m deeply grateful for your support, it truly means the world to me! Thank you!

BITCOIN

Bitcoin Logo

Bitcoin QR Code

bc1qlszw7elx2qahjwvaryh0tkgg8y68enw30gpvge

Scan the QR code with your crypto wallet app

DOGECOIN

Dogecoin Logo

Dogecoin QR Code

D64GwvvYQxFXYyan3oQCrmWfidf6T3JpBA

Scan the QR code with your crypto wallet app

ETHEREUM

Ethereum Logo

Ethereum QR Code

0xe9BC980DF3d985730dA827996B43E4A62CCBAA7a

Scan the QR code with your crypto wallet app

Please read the Privacy and Security Disclaimer on how Techcratic handles your support.

Disclaimer: As an Amazon Associate, Techcratic may earn from qualifying purchases.

Tags: Hacker News
Share162Share28ShareShare4ShareTweet101
Previous Post

OnePlus 13T leak reveals back design with all-new camera bump

Next Post

Microscopy method breaks barriers in nanoscale chemical imaging

Hacker News

Hacker News

Stay updated with Hacker News, where technology meets entrepreneurial spirit. Get the latest on tech trends, startup news, and discussions from the tech community. Read the latest updates here at Techcratic.

Related Posts

News Alert Immediately – Instant News Alerts & Global Monitoring
Hacker News

News Alert Immediately – Instant News Alerts & Global Monitoring

July 6, 2025
1.3k
hackArcana
Hacker News

hackArcana

July 6, 2025
1.3k
Differentiable Programming with PyTorch and DSPy
Hacker News

Differentiable Programming with PyTorch and DSPy

July 5, 2025
1.3k
The Right Way to Embed an LLM in a Group Chat
Hacker News

The Right Way to Embed an LLM in a Group Chat

July 5, 2025
1.3k
Cybersecurity
Hacker News

How to get into cybersecurity

July 5, 2025
1.3k
Local First Software Is Easier to Scale
Hacker News

Local First Software Is Easier to Scale

July 5, 2025
1.3k
GNU Taler
Hacker News

GNU Taler

July 5, 2025
1.3k
Impact of PCIe 5.0 Bandwidth on GPU Content Creation Performance
Hacker News

Impact of PCIe 5.0 Bandwidth on GPU Content Creation Performance

July 5, 2025
1.3k
Load More
Next Post
Microscopy method breaks barriers in nanoscale chemical imaging

Microscopy method breaks barriers in nanoscale chemical imaging

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Your Tech Resources

  • 30 Second Tech ™
  • AI
  • App Zone ™
  • Apple
  • Ars Technica
  • CNET
  • ComputerWorld
  • Crypto News
  • Cybersecurity
  • Endgadget
  • Forbes
  • Fossbytes
  • Gaming
  • GeekWire
  • Gizmodo
  • Google News
  • Hacker News
  • Harvard Tech
  • I Like Cats ™
  • I Like Dogs ™
  • LifeHacker
  • MacRumors
  • Macworld
  • Mashable
  • Microsoft
  • MIT Tech
  • PC World
  • Photofocus
  • Physics
  • Random Tech
  • Retro Rewind ™
  • Robot Report
  • SiliconANGLE
  • SlashGear
  • Smartphone
  • StackSocial
  • Tech Art
  • Tech Careers
  • Tech Deals
  • Techcratic ™
  • TechCrunch
  • Techdirt
  • TechRepublic
  • Techs Got To Eat ™
  • TechSpot
  • Tesla
  • The Verge
  • TNW
  • Trusted Reviews
  • UFO
  • VentureBeat
  • Visual Capitalist
  • Wired
  • ZDNet

Tech News

  • 30 Second Tech ™
  • AI
  • Apple Insider
  • Ars Technica
  • CNET
  • ComputerWorld
  • Crypto News
  • Cybersecurity
  • Endgadget
  • ExtremeTech
  • Fossbytes
  • Gaming
  • GeekWire
  • Gizmodo

Tech News

  • Harvard Tech
  • MacRumors
  • Macworld
  • Mashable
  • Microsoft
  • MIT Tech
  • Physics
  • PC World
  • Random Tech
  • Retro Rewind ™
  • SiliconANGLE
  • SlashGear
  • Smartphone
  • StackSocial
  • Tech Careers

Tech News​

  • Tech Art
  • TechCrunch
  • Techdirt
  • TechRepublic
  • Techs Got To Eat ™
  • TechSpot
  • Tesla
  • The Verge
  • TNW
  • Trusted Reviews
  • UFO
  • VentureBeat
  • Visual Capitalist
  • Wired
  • ZDNet

Site Links

  • About Techcratic
  • Affiliate Disclaimer
  • Affiliate Link Policy
  • Contact Techcratic
  • Dealors Discount Store
  • Privacy and Security Disclaimer
  • Privacy Policy
  • RSS Feed
  • Site Map
  • Support Techcratic
  • Techcratic
  • Tech Deals
  • TOS
  • 𝕏
Click For A Secret Deal

Techcratic – Your All In One Tech Hub © 2020 – 2025
All Rights Reserved
∞

No Result
View All Result
  • 30 Second Tech ™
  • AI
  • App Zone ™
  • Apple
  • Ars Technica
  • CNET
  • Crypto News
  • Cybersecurity
  • Endgadget
  • Gaming
  • I Like Cats ™
  • I Like Dogs ™
  • MacRumors
  • Macworld
  • Tech Deals
  • Techcratic ™
  • Techs Got To Eat ™
  • Tesla
  • UFO
  • Wired