TwoFactorInACan v0.1.0 TwoFactorInACan.Secrets View Source
Functions for generating cryptographic secrets.
Link to this section Summary
Functions
Generates a secret suitable for use in time based one time password (TOTP) two factor authentication.
Link to this section Types
Link to this type
secret_generation_opts() View Source
Link to this section Functions
Link to this function
generate_totp_secret(opts \\ [])
View Source
generate_totp_secret(opts \\ [])
View Source
generate_totp_secret(secret_generation_opts()) :: binary()
generate_totp_secret(secret_generation_opts()) :: binary()
Generates a secret suitable for use in time based one time password (TOTP) two factor authentication.
Generates a 160-bit key which is the size recommended by RFC4226 (https://www.ietf.org/rfc/rfc4226.txt).
By default, outputs a raw binary key with no encoding. The :format
key can
be used to specify alternate output formats. Valid formats include:
:binary
(default):base32
:base64
Examples
iex> TwoFactorInACan.Secrets.generate_totp_secret()
<<195, 110, 253, 36, 185, 138, 174, 16, 54, 176, 135, 67, 97, 11, 159, 63, 75, 80, 65, 6>>
iex> TwoFactorInACan.Secrets.generate_totp_secret(format: :base32)
"F2EJJEYSJA67QHI6DEAI2I6AGCEG7G5E"
iex> TwoFactorInACan.Secrets.generate_totp_secret(format: :base64)
"xKXOSYcRVlHfnazLMlRinpb252U="