|
def encrypt(message, key):
|
|
encrypted_message = ""
|
|
key_index = 0
|
|
for char in message:
|
|
if char.isalpha():
|
|
if char.islower():
|
|
shift = ord(key[key_index % len(key)].lower()) - 97
|
|
encrypted_char = chr((ord(char) - 97 + shift) % 26 + 97)
|
|
else:
|
|
shift = ord(key[key_index % len(key)].lower()) - 97
|
|
encrypted_char = chr((ord(char) - 65 + shift) % 26 + 65)
|
|
key_index += 1
|
|
else:
|
|
encrypted_char = char
|
|
encrypted_message += encrypted_char
|
|
return encrypted_message
|
|
|
|
def decrypt(encrypted_message, key):
|
|
decrypted_message = ""
|
|
key_index = 0
|
|
for char in encrypted_message:
|
|
if char.isalpha():
|
|
if char.islower():
|
|
shift = ord(key[key_index % len(key)].lower()) - 97
|
|
decrypted_char = chr((ord(char) - 97 - shift) % 26 + 97)
|
|
else:
|
|
shift = ord(key[key_index % len(key)].lower()) - 97
|
|
decrypted_char = chr((ord(char) - 65 - shift) % 26 + 65)
|
|
key_index += 1
|
|
else:
|
|
decrypted_char = char
|
|
decrypted_message += decrypted_char
|
|
return decrypted_message
|
|
|
|
import tkinter.filedialog
|
|
import tkinter.messagebox
|
|
import tkinter.simpledialog
|
|
from stegano import lsb
|
|
def hide_message(image_path, message, secret_image_path,password):
|
|
if password.strip()=="":
|
|
password="JENILSOFTWARE"
|
|
message = encrypt(message,password)
|
|
lsb.hide(image_path, message).save(secret_image_path)
|
|
def extract_message(image_path,password):
|
|
if password.strip()=="":
|
|
password="JENILSOFTWARE"
|
|
return decrypt(lsb.reveal(image_path),password)
|
|
while tkinter.messagebox.askyesno("TRY","TRYING"):
|
|
try:
|
|
if tkinter.messagebox.askyesno("hide messege or open messege","Do you want to hide messege?"):
|
|
hide_message(tkinter.filedialog.askopenfilename(filetypes=[("Image files",["*.png","*.jpg","*.jpeg"])]), tkinter.simpledialog.askstring("messege","Enter messege to hide"),tkinter.filedialog.asksaveasfilename(initialfile="hidden.png",filetypes=[("hidden png",["*.png"])]),tkinter.simpledialog.askstring("password","Enter password"))
|
|
else:
|
|
tkinter.messagebox.showinfo("messege",extract_message(tkinter.filedialog.askopenfilename(),tkinter.simpledialog.askstring("password","Enter password")))
|
|
except Exception as e:
|
|
tkinter.messagebox.showerror("error",e)
|
|
break |