From 76aec13bff5d436f1990d8dd8b621584e2c7f5b9 Mon Sep 17 00:00:00 2001 From: Jack Bond-Preston Date: Mon, 13 Feb 2023 15:52:19 +0000 Subject: [PATCH] make keygen a bit neater --- 3/keygen.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/3/keygen.py b/3/keygen.py index ced7535..2940ca1 100644 --- a/3/keygen.py +++ b/3/keygen.py @@ -1,14 +1,13 @@ import hashlib username = input("Enter your username: ") - print(f"\nUsername: {username}") -hash = int(hashlib.sha256(bytes(username, encoding="ascii")).hexdigest()[-8:], base=16) +hash = int.from_bytes(hashlib.sha256(bytes(username, encoding="ascii")).digest()[-4:], "big") print(f"SHA256-derived bytes: {hex(hash)}") target = hash ^ 0x2faecb0d print(f"Target bytes: {hex(target)}") password = target ^ 0xa2f99eae -print(f"Your password: {hex(password)[2:]}") \ No newline at end of file +print(f"Your password: {hex(password)[2:]}")