otp
Bare bones RFC4226 / RFC6238 implementation.
Installation
Install Go and install the package:
go get -u maze.io/otp.v1/...
And build it:
go build maze.io/otp.v1/cmd/totp
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
Example
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 -
fi
Usage
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