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.
Wijnand Modderman-Lenstra b6cf3cc724 Add YubiKeys support 2 years ago
cmd/totp Initial import 4 years ago
yubikey Add YubiKeys support 2 years ago
.gitignore Initial commit 4 years ago
LICENSE Initial commit 4 years ago Cleanup 4 years ago
otp.go Initial import 4 years 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