HmacOneTimePasswordGenerator

open class HmacOneTimePasswordGenerator(secret: ByteArray, config: HmacOneTimePasswordConfig)

Generator for the RFC 4226 "HOTP: An HMAC-Based One-Time Password Algorithm" (https://tools.ietf.org/html/rfc4226)

Constructors

Link copied to clipboard
fun HmacOneTimePasswordGenerator(secret: ByteArray, config: HmacOneTimePasswordConfig)

Functions

Link copied to clipboard
fun generate(counter: Long): String

Generates a code representing a HMAC-based one-time password.

Link copied to clipboard
fun isValid(code: String, counter: Long): Boolean

Validates the given code.

Link copied to clipboard
fun otpAuthUriBuilder(initialCounter: Long): OtpAuthUriBuilder.Hotp

Creates an OtpAuthUriBuilder, which pre-configured with the secret, as well as the algorithm and code digits from the config.