You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
470 B
22 lines
470 B
import hmac |
|
import hashlib |
|
import base64 |
|
|
|
|
|
def find_auth_code(password, message): |
|
if password: |
|
return base64.b64encode( |
|
hmac.digest( |
|
password.encode("utf-8"), |
|
message.encode("ascii"), |
|
"sha256", |
|
) |
|
).decode("ascii") |
|
else: |
|
return "" |
|
|
|
|
|
def find_checksum(data): |
|
return base64.b64encode( |
|
hashlib.sha256(data.encode("ascii")).digest()[:8] |
|
).decode("ascii")
|
|
|