-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecode.txt
402 lines (357 loc) · 12.7 KB
/
decode.txt
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
##This File for Text and text Document read
from stegano import lsb
import cv2
import os
import sys
import aesutil
import shutil
import numpy as np
from termcolor import cprint
from pyfiglet import figlet_format
import rsautil1
from time import *
from gtts import gTTS
from simple_colors import *
import time
from stegano import lsb
import cv2
import os
import sys
import aesutil
import shutil
import numpy as np
from termcolor import cprint
from pyfiglet import figlet_format
import rsautil1
from simple_colors import *
import time
from stegano import lsb
import cv2
import os
import sys
import aesutil
import shutil
import numpy as np
from termcolor import cprint
from pyfiglet import figlet_format
import rsautil1
from simple_colors import *
import time
from gtts import gTTS
import playsound
import os
from playsound import playsound
os.system('cls' if os.name == 'nt' else 'clear')
cprint(figlet_format('Group9', font='slant'),'green', attrs=['bold'])
print(yellow('Video Steganography', ['bold']))
print(blue('Group Members', ['bold']))
# Prajwal Atram, Hitashri Patil, Nupur Shinde, Vishal Singh, Sameer Meshram
print("\n")
print("06 - Prajwal Atram")
print("40 - Hitashri Patil")
print("54 - Nupur Shinde")
print("63 - Vishal Singh")
print("76 - Sameer Meshram")
print("\n\n")
time.sleep(2)
cprint(figlet_format('AES & RSA encrytion', font='digital'),'green', attrs=['bold'])
ENCODED_VIDEO = sys.argv[1]
temp_folder = "tmp2"
frame_choice = int(input("1) Extract and enter frame numbers from image \n2) Enter frame numbers manually : \nEnter choice: "))
decoded = {}
if frame_choice == 1:
ENCODED_IMAGE = input("\n Enter image name with extension : ")
res = lsb.reveal(ENCODED_IMAGE)
print(f"Encrypted frame numbers : {res}")
cprint("Select your encryption type \n 1) AES Encrypted {Symetric Encryption} \n 2) RSA Encrypted {Assysmetric Encryption}",'blue')
Encryption_Style=int(input(""))
if Encryption_Style == 1:
key = input("Enter the asymetric key to create AES key : ")
key_rsa = rsautil1.decrypt(message=key)
key_rsa = key_rsa.decode('utf-8')
print(f"Asymetric decrypted key \n {key_rsa}")
key123=int(input("Choose key type to decrypt image \n 2.ASCII : "))
key = input("Enter the key to decrypt image : ")
if key123==1:
msg = aesutil.decrypt(key=key,source=res)
msg1 = msg.decode('utf-8')
cprint(f"Decoded image : \n {msg}",'green')
FRAMES = list(map(int, input("Enter Above FRAME NUMBERS seperated by space: ").split()))
else:
msg = aesutil.decrypt(key=key,source=res,keyType='ascii')
msg1 = msg.decode('utf-8')
cprint(f"Decoded image: \n {msg1}",'green')
FRAMES = list(map(int, input("Enter Above FRAME NUMBERS seperated by space: ").split()))
else :
cprint("Reading private key from keys \nfolder and trying to decrypt",'red')
msg1 = rsautil1.decrypt(message=res)
msg1 = msg1.decode('utf-8')
cprint(f"Decoded image: \n {msg1}",'green')
FRAMES = list(map(int, input("Enter Above FRAME NUMBERS seperated by space: ").split()))
else :
FRAMES = list(map(int, input("Enter FRAME NUMBERS seperated by space: ").split()))
cprint("Select your decryption type \n 1) AES Encrypted {Symetric Encryption} \n 2) RSA Encrypted {Assysmetric Encryption}",'blue')
Encryption_Style=int(input(""))
#print(FRAMES)
def createTmp():
if not os.path.exists(temp_folder):
os.makedirs(temp_folder)
def countFrames():
cap = cv2.VideoCapture(ENCODED_VIDEO)
length = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
return length
def decodeVideo(number_of_frames):
# First get the frame
cap = cv2.VideoCapture(ENCODED_VIDEO)
frame_number = -1
while(frame_number<=number_of_frames):
frame_number += 1
frame_file_name = os.path.join(temp_folder,f"{frame_number}.png")
encoded_frame_file_name = os.path.join(temp_folder,f"{frame_number}-enc.png")
# print(f"Frame number {frame_number}")
ret, frame = cap.read()
if frame_number in FRAMES:
cv2.imwrite(encoded_frame_file_name,frame)
clear_message = lsb.reveal(encoded_frame_file_name)
decoded[frame_number] = clear_message
cprint(f"Frame {frame_number} DECODED: {clear_message}",'yellow')
def clean_tmp(path="./tmp2"):
if os.path.exists(path):
shutil.rmtree(path)
cprint("[INFO] tmp files are cleaned up",'yellow')
def arrangeAndDecrypt():
res=""
if Encryption_Style == 1:
for fn in FRAMES:
res = res + decoded[fn]
cprint(f"Final string: {res}",'green')
key123=int(input("Choose key type \n 2.ASCII : "))
key = input("Enter the key : ")
if key123==1:
msg = aesutil.decrypt(key=key,source=res)
msg1 = msg.decode('utf-8')
s=msg.decode()
pandu=s.split("*")
print("your text message is : "+pandu[0])
sleep(3)
print("your audio is : "+pandu[1])
# cprint(f"Decoded message: \n {msg1}",'red')
language = 'en'
mytext=pandu[1]
# Passing the text and language to the engine,
# here we have marked slow=False. Which tells
# the module that the converted audio should
# have a high speed
myobj = gTTS(text=mytext, lang=language, slow=False)
myobj.save("output.mp3")
print("Audio Successful Decoded from Video")
# Playing the converted file
playsound('output.mp3')
print("Audio Message is Playing")
sleep(3)
s=pandu[2]
li=s.split(" ")
result=[]
a=[]
b=[]
print((li))
c=0
for i in range(500):
for j in range(500):
for k in range(3):
b.append(int(li[c]))
c+=1
a.append(b)
b=[]
result.append(a)
a=[]
# ans=[]
# for i in result:
# for j in i:
# for k in j:
# ans.append(k)
# print((ans))
result=np.asarray(result)
result=result.astype(np.uint8)
# print(result.shape)
print(type(result))
cv2.imshow('Hidden Image',result)
print("Wait until Image Opens!!")
cv2.waitKey(0)
sleep(3)
s=pandu[3]
li=s.split(" ")
# print(len(li))
c=0
while(c<len(li)):
result=[]
a=[]
b=[]
for i in range(300):
for j in range(300):
for k in range(3):
b.append(int(li[c]))
c+=1
a.append(b)
b=[]
result.append(a)
a=[]
result=np.asarray(result)
# cv2.imshow('avc',result)
result=result.astype(np.uint8)
cv2.imshow('avc',result)
cv2.waitKey(1000)
# li=s.split(" ")
# result=[]
# a=[]
# b=[]
# print((li))
# c=0
# for i in range(154):
# for j in range(328):
# for k in range(3):
# b.append(int(li[c]))
# c+=1
# a.append(b)
# b=[]
# result.append(a)
# a=[]
# # ans=[]
# # for i in result:
# # for j in i:
# # for k in j:
# # ans.append(k)
# # print((ans))
# result=np.asarray(result)
# result=result.astype(np.uint8)
# # print(result.shape)
# print(type(result))
# cv2.imshow('avc',result)
# cv2.waitKey(0)
cprint(f"Decoded message: \n {msg}",'green')
clean_tmp()
else:
msg = aesutil.decrypt(key=key,source=res,keyType='ascii')
msg1 = msg.decode('utf-8')
s=msg.decode()
pandu=s.split("*")
print("your text message is : "+pandu[0])
sleep(3)
print("your audio is : "+pandu[1])
# cprint(f"Decoded message: \n {msg1}",'red')
language = 'en'
mytext=pandu[1]
# Passing the text and language to the engine,
# here we have marked slow=False. Which tells
# the module that the converted audio should
# have a high speed
myobj = gTTS(text=mytext, lang=language, slow=False)
myobj.save("output.mp3")
print("Audio Successful Decoded from Video")
# Playing the converted file
playsound('output.mp3')
print("Audio Message is Playing")
sleep(3)
s=pandu[2]
li=s.split(" ")
print(len(li))
result=[]
a=[]
b=[]
print((li))
c=0
for i in range(168):
for j in range(300):
for k in range(3):
b.append(int(li[c]))
c+=1
a.append(b)
b=[]
result.append(a)
a=[]
# ans=[]
# for i in result:
# for j in i:
# for k in j:
# ans.append(k)
# print((ans))
result=np.asarray(result)
result=result.astype(np.uint8)
# print(result.shape)
print(type(result))
cv2.imshow('Hidden Image',result)
print("Wait until Image Opens!!")
cv2.waitKey(4000)
sleep(3)
s=pandu[3]
li=s.split(" ")
# print(len(li))
c=0
while(c<len(li)):
result=[]
a=[]
b=[]
for i in range(300):
for j in range(300):
for k in range(3):
b.append(int(li[c]))
c+=1
a.append(b)
b=[]
result.append(a)
a=[]
result=np.asarray(result)
# cv2.imshow('avc',result)
result=result.astype(np.uint8)
cv2.imshow('avc',result)
cv2.waitKey(1000)
# s=msg.decode()
# print(type(s))
# # print(s)
# li=[]
# li=s.split(" ")
# result=[]
# a=[]
# b=[]
# # print((li))
# c=0
# for i in range(154):
# for j in range(328):
# for k in range(3):
# b.append(int(li[c]))
# c+=1
# a.append(b)
# b=[]
# result.append(a)
# a=[]
# # ans=[]
# # for i in result:
# # for j in i:
# # for k in j:
# # ans.append(k)
# # print((ans))
# result=np.asarray(result)
# result=result.astype(np.uint8)
# # print(result.shape)
# print(type(result))
# cv2.imshow('avc',result)
# cv2.waitKey(0)
cprint(f"Decoded message: \n {msg1}",'red')
# msg1.save("output.mp3")
# Playing the converted file
# os.system("output.mp3")
clean_tmp()
else :
for fn in FRAMES:
res = res + decoded[fn]
cprint(f"Final string: {res}",'green')
cprint("Reading private key from keys folder \nand trying to decrypt",'red')
msg1 = rsautil1.decrypt(message=res)
msg1 = msg1.decode('utf-8')
cprint(f"Decoded text: \n {msg1}",'green')
clean_tmp()
createTmp()
frames = countFrames()
decodeVideo(frames)
arrangeAndDecrypt()
# pip3 install gTTS pyttsx3