Skip to content

jam.otp.BaseOTP

BaseOTP

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

Base *OTP.

Parameters:

Name Type Description Default
secret bytes | str

Secret key(str or Byte32).

required
digits int

Number of digits in the code. Default is 6.

6
digest str

Hash algorithm (sha1, sha256, sha512). Default is sha1.

'sha1'

Methods:

Name Description
provisioning_uri

Generates an otpauth:// URI for Google Authenticator.

provisioning_uri

provisioning_uri(
    name: str,
    issuer: str,
    type_: str = "totp",
    counter: Optional[int] = None,
) -> str

Generates an otpauth:// URI for Google Authenticator.

Parameters:

Name Type Description Default
name str

Account name (e.g., email).

required
issuer str

Service name (e.g., "GitHub").

required
type_ str

OTP type (“totp” or 'hotp'). Default is "totp".

'totp'
counter int | None

Counter (for HOTP). Default is None.

None

Returns:

Name Type Description
str str

A string of the form "otpauth://..."

FILE PATH: jam/otp/__abc_module__.py