Authenticator¶
¶
Authenticator
¶
Authenticator class which generates unique one time use password.
__init__(self, secret)
special
¶
Creates a new Authenticator instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
secret |
str |
User secret which is used in generating one time password. |
required |
Returns:
Type | Description |
---|---|
|
Authenticator instance. |
Source code in authenticatorpy/authenticator.py
14 15 16 17 18 19 20 21 22 23 24 25 |
|
create_hmac(self, secret, input)
¶
Creates the hash value which is used in creating one time password.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
secret |
str |
User secret which is used in generating one time password. |
required |
input |
float |
The value of current UNIX time divided by 30. |
required |
Returns:
Type | Description |
---|---|
str |
SHA1 hash value. |
Source code in authenticatorpy/authenticator.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
current_timestamp(self)
¶
Returns the current UNIX time.
Source code in authenticatorpy/authenticator.py
87 88 89 90 |
|
decode_with_base32(self, upper_case_secret)
¶
Creates a new Base32 decoded value from given string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
upper_case_secret |
str |
User secret which is used in generating one time password. |
required |
Returns:
Type | Description |
---|---|
bytes |
Base32 decoded value. |
Source code in authenticatorpy/authenticator.py
75 76 77 78 79 80 81 82 83 84 85 |
|
one_time_password(self, delay_time=30.0)
¶
Creates one time password using secret which must be set in constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
delay_time |
float |
Optional time interval for token availability. |
30.0 |
Returns:
Type | Description |
---|---|
str |
One time password as string. |
Source code in authenticatorpy/authenticator.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|
remove_spaces(self, secret)
¶
Removes empty spaces from given string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
secret |
str |
User secret which is used in generating one time password. |
required |
Returns:
Type | Description |
---|---|
str |
String without empty spaces. |
Source code in authenticatorpy/authenticator.py
49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
to_upper_case(self, secret_without_spaces)
¶
Updates given string to uppercase without changing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
secret_without_spaces |
str |
User secret which is used in generating one time password. |
required |
Returns:
Type | Description |
---|---|
str |
String in uppercase. |
Source code in authenticatorpy/authenticator.py
63 64 65 66 67 68 69 70 71 72 73 |
|