Happily for us Emacsers, Mickey has been blogging up a storm on Emacs topics lately. His latest offering is on generating TOPT codes with Emacs. TOPT is “Time-Based One-Time Password”. If that doesn’t mean anything to you, it’s the basis of those two-factor fobs that many us do or have carried around that gives you code to use as part of a login. Here’s one example but there are many others.
The fobs work by combining the time with a domain-specific secret and hashing them with SHA1 to generate the code. The TOTP protocol handles things like the inevitable time drift of the fob’s clock. At bottom, though, there’s nothing very mysterious about the protocol and it’s certainly possible to roll your own.
Mickey has done just that. He’s slightly modified Jürgen Hötzel’s totp.el
and provided his own version of a base-32 decoder so that the resulting implementation is standalone. You can add his code to your init.el
and generate your TOTP codes directly from within Emacs. The only thing you need is the secret but that is typically provided the the TOTP provider. Be sure to check out Mickey’s post for all the details.
If nothing else, this is a nice way of reducing your “everyday carry”, something that we here at Irreal are always interested in doing. If you’re logging in using Emacs, it’s also a way of avoiding the trauma of having to leave Emacs. What’s not to like?