jam.utils.otp_keys
otp_keys
¶
Functions:
Name | Description |
---|---|
generate_otp_key |
Generate generic OTP secret key. |
otp_key_from_string |
Generate OTP-valid key from string. |
generate_otp_key
¶
generate_otp_key(entropy_bits: int = 128) -> str
Generate generic OTP secret key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entropy_bits
|
int
|
Entropy bits to key |
128
|
Returns:
Type | Description |
---|---|
str
|
str |
otp_key_from_string
¶
otp_key_from_string(s: str) -> str
Generate OTP-valid key from string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
s
|
str
|
String for key |
required |
Returns:
Name | Type | Description |
---|---|---|
bytes |
str
|
OTP key |
Example
>>> from jam.utils import otp_key_from_string
>>> user_email: str = "some.email@mail.com"
>>> key = otp_key_from_string(user_email)
>>> print(key)
'O54O6YRKTH3IPNEBIUMKMK3FZ35OF6Q5'
FILE PATH: jam/utils/otp_keys.py