from hashlib import sha512
import secrets
import string

# Transaction verifier
# Paste it to sites like https://tio.run/#python3 or https://www.online-python.com/ if you want to use it inside browser
# Local interpreter of python 3 will work with standart library only
# Edit CONFIG and insert you values
# CONFIG
game_number_with_salt = "Lucky number from 00 to 99 with cryptographic salt. Revealed at the end of the game, script can be run without it."
tx_hash = "Transaction hash here"
block_hash = "Hash of first block which includes transaction here"
# CONFIG END


def random_number(below):
    number = secrets.randbelow(below)
    return(f"{number:02d}")


def random_string(num_symbols):
    alphabet = string.ascii_letters + string.digits
    return ''.join(secrets.choice(alphabet) for i in range(num_symbols))


def sha512_hash_str_int(input_text):
    hash_raw = sha512(input_text.encode('utf-8'))
    hash_hex = hash_raw.digest()
    hash_int = int.from_bytes(hash_hex, 'big')
    return hash_raw.hexdigest(), hash_int

print("Transaction combined hash and full transaction hash number:\n", sha512_hash_str_int(tx_hash.strip()+block_hash.strip()))
secret_hash = sha512(game_number_with_salt.strip().encode('utf-8')).hexdigest()
print("Hashed lucky number:\n", secret_hash)