File size: 2,826 Bytes
ffdfff9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
def encrypt(message, key):
    encrypted_message = ""
    key_index = 0
    for char in message:
        if char.isalpha():  # Only encrypt alphabetic characters
            if char.islower():
                shift = ord(key[key_index % len(key)].lower()) - 97
                encrypted_char = chr((ord(char) - 97 + shift) % 26 + 97)  # Encrypt lowercase letters
            else:
                shift = ord(key[key_index % len(key)].lower()) - 97
                encrypted_char = chr((ord(char) - 65 + shift) % 26 + 65)  # Encrypt uppercase letters
            key_index += 1
        else:
            encrypted_char = char  # Leave non-alphabetic characters unchanged
        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():  # Only decrypt alphabetic characters
            if char.islower():
                shift = ord(key[key_index % len(key)].lower()) - 97
                decrypted_char = chr((ord(char) - 97 - shift) % 26 + 97)  # Decrypt lowercase letters
            else:
                shift = ord(key[key_index % len(key)].lower()) - 97
                decrypted_char = chr((ord(char) - 65 - shift) % 26 + 65)  # Decrypt uppercase letters
            key_index += 1
        else:
            decrypted_char = char  # Leave non-alphabetic characters unchanged
        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