-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.py
145 lines (117 loc) · 4.28 KB
/
main.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
from steganolib import stegano_az as stg_az
from steganolib import bitgen as bg
def algo_menu(choice,typef,algo_choice=0):
ch = int(input("Enter number of image files to use : "))
if choice is 1:
fileIn_loc = input('Enter the location of input data file : ')
fileIn_name = input('Enter the name of the input data file WITH extention : ')
fileIn = fileIn_loc + '/' + fileIn_name
file = open(fileIn)
reader = file.read()
file.close()
reader_db = bg.chunk(reader,ch)
elif choice is 2:
fileOut_loc = input('Enter the location of output data file : ')
fileOut_name = input('Enter the name of the output data file WITH extention : ')
fileOut = fileOut_loc + '/' + fileOut_name
file = open(fileOut,'w')
data_base ={}
if choice is 1:
for i in range(ch):
print('Enter for image no :',(i+1))
imageIn_loc = input('Enter the source image location : ')
imageIn_name = input('Enter the image file name WITH extention : ')
imageOut_loc = input('Enter the output image location : ')
imageOut_name = input('Enter the image file name WITHOUT extention : ')
imageIn = imageIn_loc + '/' + imageIn_name
imageOut = imageOut_loc + '/' + imageOut_name + '.png'
if algo_choice is 1:
meta = 'lsb' + '|' + str(i) + ':'
stg_az.lsb_embed(reader_db[i],imageIn,imageOut,typef,meta)
elif algo_choice is 2:
meta = 'lsa' + '|' + str(i) + ':'
stg_az.lsb_alpha_embed(reader_db[i],imageIn,imageOut,typef,meta)
print('Successfully embeded')
elif choice is 2:
for i in range(ch):
print('Extracting from image no :',(i+1))
imageOut_loc = input('Enter the output image location : ')
imageOut_name = input('Enter the image file name WITHOUT extention : ')
imageOut = imageOut_loc + '/' + imageOut_name + '.png'
data_base.update(stg_az.retv(imageOut,typef))
print('Successfully retrieved')
for order in range(ch):
file.write(data_base[order])
file.close()
print('Merged to file')
def watermarking(choice):
if choice is 3:
ch = int(input("Enter number of image files for: "))
mark = input('Enter the water mark : ')
for i in range(ch):
print('Enter for image no :',(i+1))
imageIn_loc = input('Enter the source image location : ')
imageIn_name = input('Enter the image file name WITH extention : ')
imageOut_loc = input('Enter the output image location : ')
imageOut_name = input('Enter the image file name WITHOUT extention : ')
imageIn = imageIn_loc + '/' + imageIn_name
imageOut = imageOut_loc + '/' + imageOut_name + '.png'
stg_az.water(imageIn,imageOut,mark)
print('Water marking Successful')
else:
ch = int(input("Enter number of image files for checking signature : "))
mark = input('Enter the water mark for checking the ownership : ')
for i in range(ch):
print('Enter for image no :',(i+1))
imageOut_loc = input('Enter the output image location : ')
imageOut_name = input('Enter the image file name WITHOUT extention : ')
imageOut = imageOut_loc + '/' + imageOut_name + '.png'
if stg_az.validate(imageOut,mark) is True:
print('Water mark found')
else:
print('Water mark not found')
def menu():
print('Choose a method or press 0 to exit\n1.Embed\n2.Retrieve\n3.Water Mark\n4.Check Ownership')
choice = int(input('Enter your choice : '))
print('\n')
if choice is 0:
exit()
elif choice is 1:
print('Choose a file type\n1.Text')
isvalid = False
while not isvalid:
typef = int(input('Enter your choice : '))
if typef in [1]:
isvalid = True
else:
print('Invalid choice enter again')
print('\n')
print('Choose an algorithm\n1.Least Significant Bit(LSB)\n2.Least Significant Bit alpha only(LSB_alpha)')
isvalid = False
while not isvalid:
algo_choice = int(input('Enter your choice : '))
if algo_choice in [1,2]:
isvalid = True
algo_menu(choice,typef,algo_choice)
else:
print('Invalid choice enter again')
elif choice is 2:
print('Choose a file type\n1.Text')
isvalid = False
while not isvalid:
typef = int(input('Enter your choice : '))
if typef in [1]:
isvalid = True
else:
print('Invalid choice enter again')
print('\n')
algo_menu(choice,typef)
elif choice is 3 or choice is 4:
watermarking(choice)
else:
print('Invalid option')
print("Image Stegagraphy Lab")
print('\n'*2)
while True:
menu()
print('\n'*2)