Add example tocken encryption pyhton function

This commit is contained in:
sebivh
2025-10-17 14:01:46 +02:00
parent a0157292cc
commit 1115b7378f

26
token.py Normal file
View File

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