27 lines
830 B
Python
27 lines
830 B
Python
# 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)
|