Main Content

CircuitPython 2FA TOTP Authentication Friend

What is TOTP?
Having 2 Factor Authentication on all your accounts is a good way to keep your data more secure. With 2FA logins, not only is a username and password needed, but also a one-time-use code. There’s a few different ways to get that code, such as by email, phone or SMS. But my favorite way is to do it is via a ‘Google Authenticator’ time-based OTP (one time password), also known as a TOTP.

Using an app on your phone like Authy or Authenticator, you set up a secret given to you by the service, then every 30 seconds, a new code is generated for you. What’s extra nice is that the Google Authenticator protocol is supported by just about every service and phone/tablet

So What’s The Problem?
I don’t own a phone! So I have to ask Mr. Ladyada for an authenticator code. Or I can use my tablet, but it’s not always at my desk. And I don’t want to buy a phone just for using 2FA!

A Solution!
Luckily for us, the Google Authenticator protocol is really simple - You just need to be able to know the current time, and run a SHA1 hash.

I decided to build a simple device that all it does is generate TOTP’s for me, using CircuitPython - my favorite programming language! It uses a Feather ESP8266 which has WiFi so it can connect to NTP to get the current time on startup, and a Feather OLED to display text nice and clearly.

Every time I need a new code, I just click the reset button and within 2 seconds I’ve got my 3 most common TOTP’s on hand (yes its that fast!)”

Link to article