-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStegi_Suman.py
122 lines (120 loc) · 4.98 KB
/
Stegi_Suman.py
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
from tkinter import *
from tkinter.filedialog import *
from stegano import exifHeader as stg
from tkinter import messagebox
import glob
import os
from os import path
def encode():
main.destroy()
enc = Tk()
enc.title("encode")
enc.geometry("500x400+300+150")
label1 = Label(text="Secret Message")
label1.place(relx=0.1, rely=0.1, height=20, width=100)
entry = Entry()
entry.place(relx=0.4, rely=0.1)
label2 = Label(text="File name")
label2.place(relx=0.1, rely=0.2, height=20, width=100)
entrysave = Entry()
entrysave.place(relx=0.4, rely=0.2)
def openfile():
global fileopen
fileopen = StringVar()
fileopen = askopenfilename(initialdir='/Desktop', title='select file', filetypes=(("jpeg files", "*jpg"), ("all files", "*.*")))
label3 = Label(text=fileopen)
label3.place(relx=0.3, rely=0.3)
def encodee():
response = messagebox.askyesno("pop up", "do you want to encode")
if response == 1:
stg.hide(fileopen,entrysave.get()+'.jpg', entry.get())
messagebox.showinfo("pop up", "successfully encode")
else:
messagebox.showwarning("pop up", "unsuccessful")
buttonselect = Button(text='select file', command=openfile)
buttonselect.place(relx=0.1, rely=0.3)
buttonencode= Button(text="Encode", command=encodee)
buttonencode.place(relx=0.4, rely=0.5)
def encodei():
main.destroy()
enc = Tk()
enc.title("encode")
enc.geometry("500x400+300+150")
label7 = Label(text="cover")
label7.place(relx=0.1, rely=0.1, height=20, width=100)
label8 = Label(text="hidden")
label8.place(relx=0.1, rely=0.2, height=20, width=100)
L = []
def openfile():
global fileopen
fileopen = StringVar()
fileopen = askopenfilename(initialdir='/Desktop', title='select file',filetypes=(("jpeg files", "*jpg"), ("all files", "*.*")))
label3 = Label(text=fileopen)
label3.place(relx=0.1, rely=0.3)
a= str(path.abspath(fileopen))
L.append(a)
def openfile1():
global fileopen1
fileopen1 = StringVar()
fileopen1 = askopenfilename(initialdir='/Desktop', title='select file',filetypes=(("jpeg files", "*jpg"), ("all files", "*.*")))
label9 = Label(text=fileopen1)
label9.place(relx=0.1, rely=0.4)
b=str(path.abspath(fileopen1))
L.append(b)
def encodee1():
try:
os.system(f'cmd /k "copy /b "{L[0]}"+ "{L[1]}" Final.jpg"')
except:
print('Image Not Encoded')
buttonselect = Button(text='Cover', command=openfile)
buttonselect.place(relx=0.5, rely=0.1)
buttonselect = Button(text='Hiden', command=openfile1)
buttonselect.place(relx=0.5, rely=0.2)
buttonencode = Button(text="Encode", command=encodee1)
buttonencode.place(relx=0.4, rely=0.5)
def decode():
main.destroy()
dnc = Tk()
dnc.title("decode")
dnc.geometry("500x400+300+150")
def openfile():
global fileopen
fileopen = StringVar()
fileopen = askopenfilename(initialdir='/Desktop', title='select file', filetypes=(("jpeg files", "*jpg"), ("all files", "*.*")))
def decodee():
message= stg.reveal(fileopen)
label4= Label(text=message)
label4.place(relx=0.3,rely=0.3)
buttonselect = Button(text='select file', command=openfile)
buttonselect.place(relx=0.1, rely=0.3)
buttonencode = Button(text="Decode", command=decodee)
buttonencode.place(relx=0.4, rely=0.5)
def decodei():
main.destroy()
dnc = Tk()
dnc.title("decode")
dnc.geometry("500x400+300+150")
magic_numbers = {'jpg': bytes([0xFF, 0xD8, 0xFF, 0xE0])}
for x in glob.glob("*jpg"):
with open(x, 'rb') as fd:
file_data = fd.read()
print("Detected " + str(file_data.count(magic_numbers['jpg'])) + " JPG files in file : " + fd.name)
if file_data.count(magic_numbers['jpg']) > 1:
print("Trying to extract embedded files")
for f in range(file_data.count(magic_numbers['jpg'])):
with open(str(f + 1) + ".jpg", "wb") as ff:
ff.write(magic_numbers['jpg'] + file_data.split(magic_numbers['jpg'])[f + 1])
print("Generated file : " + str(f + 1) + ".jpg")
messagebox.showinfo("pop up", "successfully Decoded Image")
main = Tk()
main.title("img stegano")
main.geometry("500x400+300+150")
encodebi = Button(text='Encode Image', command=encodei)
encodebi.place(relx=0.1, rely=0.3, height=40, width=100)
encodeb = Button(text='Encode Message', command=encode)
encodeb.place(relx=0.3, rely=0.3, height=40, width=100)
decodeb = Button(text='Decode Message', command=decode)
decodeb.place(relx=0.5, rely=0.3, height=40, width=100)
decodebi = Button(text='Decode Image', command=decodei)
decodebi.place(relx=0.7, rely=0.3, height=40, width=100)
main.mainloop()