Created
November 26, 2022 17:09
-
-
Save albertosottile/97d001ed6177ef8cad9b6680af57f84f to your computer and use it in GitHub Desktop.
cryptography issue #7847
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cryptography.fernet import Fernet | |
from tkinter import * | |
class Application(Frame): | |
def encrypt(self): | |
if not self.encrypted: | |
self.message = self.fernet.encrypt(self.message.encode()).decode() | |
self.encrypted = True | |
self.labeltext.set(self.message) | |
def decrypt(self): | |
if self.encrypted: | |
self.message = self.fernet.decrypt(self.message).decode() | |
self.encrypted = False | |
self.labeltext.set(self.message) | |
def createWidgets(self): | |
frame1 = Frame(self) | |
frame1.pack(fill=X) | |
self.labeltext = StringVar() | |
self.labeltext.set(self.message) | |
self.label = Label(frame1, textvariable=self.labeltext) | |
self.label.pack(fill=X, padx=100) | |
frame2 = Frame(self) | |
frame2.pack(fill=X) | |
self.QUIT = Button(frame2, text="Quit", command=self.quit) | |
self.QUIT.pack({"side": "left"}) | |
self.encrypt = Button(frame2, text="Encrypt", command=self.encrypt) | |
self.encrypt.pack({"side": "left"}) | |
self.decrypt = Button(frame2, text="Decrypt", command=self.decrypt) | |
self.decrypt.pack({"side": "left"}) | |
def __init__(self, master=None): | |
self.message = "Some Text" | |
self.encrypted = False | |
key = Fernet.generate_key() | |
self.fernet = Fernet(key) | |
Frame.__init__(self, master) | |
self.pack() | |
self.createWidgets() | |
app = Application() | |
app.mainloop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Script for building the example. | |
Usage: | |
python setup.py py2app | |
""" | |
from setuptools import setup | |
setup( | |
app=['hello.py'], | |
setup_requires=["py2app"], | |
options={'py2app': {'includes': {'cffi'}}} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment