write-ups-challenges-2022-2023/super-hightech-paint/super-hightech-paint-1/buildfiles/keys/generator.py
2022-11-24 22:59:22 +01:00

21 lines
415 B
Python

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))