Skip to content

jam.otp.HOTP

HOTP

HOTP(
    secret: Union[bytes, str],
    digits: int = 6,
    digest: Literal["sha1", "sha256", "sha512"] = "sha1",
)

Bases: BaseOTP

HOTP instance.

Methods:

Name Description
at

Generates a HOTP code for the specified counter.

verify

Verify HOTP-code.

at

at(factor: int) -> str

Generates a HOTP code for the specified counter.

Parameters:

Name Type Description Default
factor int

Counter (increases after each use).

required

Returns:

Name Type Description
str str

HOTP code (fixed-length string).

verify

verify(code: str, factor: int, look_ahead: int = 1) -> bool

Verify HOTP-code.

Parameters:

Name Type Description Default
code str

Code.

required
factor int

Now counter.

required
look_ahead int

Allowable forward offset (to compensate for desynchronization). Default is 1..

1

Returns:

Name Type Description
bool bool

True if the code matches, otherwise False.

FILE PATH: jam/otp/hotp.py