write-ups-challenges-2022-2023/super-hightech-paint/super-hightech-paint-1/buildfiles/keys/generator.py

21 lines
415 B
Python
Raw Permalink Normal View History

2022-11-24 21:59:22 +00:00
import random
def generate_key(nonce: int):
def fmt(x):
return "{:04x}".format(x)
a = 65536 % nonce
b = 65536 % (65536 - nonce)
c = a ^ b
key = ["SHTP"]
key.append(fmt(a))
key.append(fmt(b))
key.append(fmt(c))
print('-'.join(key))
generate_key(random.randint(256, 65536-256))
generate_key(random.randint(256, 65536-256))
generate_key(random.randint(256, 65536-256))