From 1115b7378fad48b6254089c5e3fd348962074080 Mon Sep 17 00:00:00 2001 From: sebivh Date: Fri, 17 Oct 2025 14:01:46 +0200 Subject: [PATCH] Add example tocken encryption pyhton function --- token.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 token.py diff --git a/token.py b/token.py new file mode 100644 index 0000000..bdc8d48 --- /dev/null +++ b/token.py @@ -0,0 +1,26 @@ +# Function that generates a token depending on unsername and masterpassword +# The masterpassword must be 32 characters long! +def create_token(username, masterpassword): + + if len(masterpassword) != 32: + print("Masterpassword must be 32 characters long") + exit(1) + + padded_username = username.ljust(32, ':') + + token = bytearray() + # xor connect with masterpassword to create token + for i in range(32): + token.append(ord(padded_username[i]) ^ ord(masterpassword[i])) + + str_token = token.hex() + return str_token + + +if __name__ == "__main__": + # request username and masterpassword + username = input("Enter your username: ") + masterpassword = input("Enter your masterpassword (32 characters): ") + + token = create_token(username, masterpassword) + print("Your token is: " + token)