Bare bones RFC4226 / RFC6238 implementation
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
maze 2415e236cc Cleanup 1 year ago
cmd/totp Initial import 1 year ago
.gitignore Initial commit 1 year ago
LICENSE Initial commit 1 year ago Cleanup 1 year ago
otp.go Initial import 1 year ago


Bare bones RFC4226 / RFC6238 implementation.


Install Go and install the package:

go get -u

And build it:

go build

Now place the totp binary in your $PATH.

Tokens from (go)pass

For base32-encoded secrets stored in (go)pass, it’s easy to generate tokens:

gopass path/to/totp | totp


An example using dmenu en xdotool may look like:

SECRET=$(gopass list | grep 'totp' | dmenu)
if [ -n $SECRET ]; then
    (echo -n "type "; gopass "$SECRET" | totp) | xdotool -


The following flags are available to the totp command:

-digits int
  	number of output digits (default 6)

-encoding string
  	secret encoding (default "base32")

-period int
  	period (default 30)

The following encodings are supported:

base32  RFC4648 base32 encoding (default)
base64  RFC4648 base64 encoding
hex     Hexadecimal encoding (each byte is encoded as two hex nibbles)
ascii   Secret is used as-is