I was trying to use a library I found in python called fernet and make a simple program encrypting and decrypting in python and it worked but when I tried to make it GUI it kept spiting out the error "invalid token". I don't know what I did wrong but it seems that it is only throwing a error in the GUI, Can someone help? (Just so you know I am not the smartest in python so can you explain in simple terms)
Here is the full error:
line 121, in _get_unverified_token_data raise InvalidToken cryptography.fernet.InvalidToken
from cryptography.fernet import Fernet
from tkinter import *
import tkinter as tk
def Encrypt():
get=tk.StringVar()
message=get.get()
byte_message = str.encode(message)
f = Fernet(b'U_v31LOlh9SOe3eN-18CNUropIalPD02eqxgTxUnuAI=')
encrypted_message = f.encrypt(byte_message)
enmess.config(text = encrypted_message.decode(), font=('Poppins',5))
def Decrypt():
get=tk.StringVar()
message=get.get()
f = Fernet(b'U_v31LOlh9SOe3eN-18CNUropIalPD02eqxgTxUnuAI=')
message = str.encode(message)
encrypted_message = f.decrypt(message)
print(encrypted_message.decode())
#decrypt_message = f.decrypt(b'gAAAAABkTNLJxD-1doUad45Srrb0vku4QdC0sQ-KZLr4-Z5OdgJ5R118ApojM-3HQTc3_YcYLJ6FYNQgYylc1V9QE2G_lTt1_A==')
#print(decrypt_message)
root=tk.Tk()
root.geometry("600x400")
message=tk.StringVar()
name_label = tk.Label(root, text = "Enter Message", font=('Poppins',10, 'bold'))
name_entry = tk.Entry(root,textvariable = message, font=('Poppins',10,'normal'))
enmess = tk.Label(root, text = "will be updated soon", font=('Poppins',10))
encrypt_btn=tk.Button(root,text = 'Encrypt', command = Encrypt)
decrypt_btn=tk.Button(root,text = 'Decrypt', command = Decrypt)
name_label.grid(row=0,column=1)
name_entry.grid(row=0,column=2)
encrypt_btn.grid(row=2,column=1)
decrypt_btn.grid(row=2,column=2)
enmess.grid(row=3, column=0)
root.mainloop()
I fiddled around a lot and so the code may look a little weird but thank you for your help (: