Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
digistore python validate thank you page
from hashlib import sha512
from urllib.parse import parse_qs, unquote
def is_digistore_query_valid(qs, thankyou_page_key):
qs_dict = {key: unquote(value[0]) for key, value in parse_qs(qs).items()}
expected_sha = qs_dict.pop('sha_sign')
sha_string = ''
for key, value in sorted(qs_dict.items()):
sha_string += f'{key}={value}{thankyou_page_key}'
m = sha512()
m.update(sha_string.encode('utf-8'))
actual_sha = m.digest().hex().upper()
return actual_sha == expected_sha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment