Totpex v0.1.4 Totpex View Source

Generate a Time-Based One-Time Password used from 2 factor authentication. Official specification: https://tools.ietf.org/html/rfc6238

To accomodate Google Authenticator secrets are accepted with or without padding.

Link to this section Summary

Functions

Generate Time-Based One-Time Password. The default period used to calculate the moving factor is 30s

Validate Time-Based One-Time Password. Accepts the following options

Link to this section Functions

Link to this function

generate_time_offsets(period, num)

View Source
Link to this function

generate_totp(secret, period \\ 30, time \\ nil)

View Source

Generate Time-Based One-Time Password. The default period used to calculate the moving factor is 30s

The secret should be valid Base32 encoded, with or without padding.

Examples

iex> generate_totp(Base.encode32("My secret"))
"79727"
Link to this function

validate_totp(secret, totp, opts \\ [])

View Source

Validate Time-Based One-Time Password. Accepts the following options:

  • :period - moving factor in integer seconds (integer, default 30)
  • :grace_periods - number of periods offset from current time to accept as valid tokens (integer, default 0)