Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from tkinter import filedialog
- root = Tk()
- root.config(bg='black')
- root.title('Najeeb Secret Image')
- root.geometry("320x100")
- def encrypt_image():
- file1 = filedialog.askopenfile(mode='rb', filetype=[('Image Files', '*.jpg;*.png;*.jpeg;*.bmp;*.gif')])
- if file1 is not None:
- file_name = file1.name
- key = entry1.get(1.0, END).strip()
- fi = open(file_name, 'rb')
- image = bytearray(fi.read())
- fi.close()
- for index, value in enumerate(image):
- image[index] = value ^ int(key)
- fil = open(file_name, 'wb')
- fil.write(image)
- fil.close()
- Label(root.master, text='Enter Secret Key :', font='10', bg='black', fg='yellow').place(x=10, y=10)
- entry1 = Text(root, height=1, width=16)
- entry1.place(x=150, y=10)
- b1 = Button(root, text="IMAGE ENCRYPT", command=encrypt_image)
- b1.place(x=15, y=50)
- b1 = Button(root, text="IMAGE DECRYPT", command=encrypt_image)
- b1.place(x=180, y=50)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement