2024-10-18 00:19:39 +00:00
|
|
|
import random
|
2024-10-18 00:57:39 +00:00
|
|
|
import string
|
2024-10-18 00:19:39 +00:00
|
|
|
|
|
|
|
def generate_salt(length=16):
|
2024-10-18 00:57:39 +00:00
|
|
|
# Generate a salt with alphanumeric characters (A-Z, a-z, 0-9)
|
|
|
|
return 'SALT' + ''.join(random.choices(string.ascii_letters + string.digits, k=length))
|
2024-10-18 00:19:39 +00:00
|
|
|
|
2024-10-18 00:57:39 +00:00
|
|
|
def generate_proof_of_work():
|
|
|
|
# Randomize memory cost, time cost, and difficulty
|
|
|
|
memory_cost = random.randint(1, 262144) # Up to 262144
|
|
|
|
time_cost = 1 # Always set to 1
|
|
|
|
salt = generate_salt()
|
|
|
|
difficulty = random.randint(1000, 1500) # Between 1000 and 1500
|
|
|
|
|
|
|
|
# Format the challenge code
|
|
|
|
proof_of_work_code = f"{memory_cost}:{time_cost}:{salt}:{difficulty}"
|
|
|
|
print(f"Generated Proof of Work Code: {proof_of_work_code}")
|
2024-10-18 00:19:39 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2024-10-18 00:57:39 +00:00
|
|
|
generate_proof_of_work()
|