Created
December 16, 2022 12:47
-
-
Save milosev1c/1608b5c01bb36fcd45f6c07c7471c44f to your computer and use it in GitHub Desktop.
how to check telegram auth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def check_hash(body): | |
secret_key = sha256(os.environ.get("TG_TOKEN", "").encode()).digest() | |
hash_string = body.pop("hash") | |
data_string = [f"{key}={value}" for key, value in body.items()] | |
data_string = "\n".join(sorted(data_string)) | |
return hmac.new(secret_key, data_string.encode(), sha256).hexdigest() == hash_string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment