From 3e16db62f1d03635b015672929af48aa29b1c3ee Mon Sep 17 00:00:00 2001 From: mankotia412vishal Date: Tue, 22 Aug 2023 14:39:50 +0530 Subject: [PATCH] FIX #1 Enhancement: Extending Project ..... --- AES-ENC-Key/ReceiverKey.txt | 1 + AES-ENC-Key/note.md | 2 + Backup Files/app.py | 65 + Backup Files/decode.py | 440 + Backup Files/encode.py | 632 + Backup Files/encrypt.html | 121 + DecodeVideo.py | 197 + Message.txt | 1 + README.md | 63 +- SECURITY.md | 21 + Vishal/app.py | 65 + Vishal/decode.py | 451 + Vishal/encode.py | 630 + Vishal/static/assets/favicon.ico | Bin 0 -> 23462 bytes Vishal/static/css/bootstrap.min.css | 6 + Vishal/static/css/style.css | 125 + Vishal/static/css/styles.css | 11248 +++++++++++++++++ Vishal/static/images/1.jpeg | Bin 0 -> 7142 bytes Vishal/static/images/coded-data.gif | Bin 0 -> 2747152 bytes Vishal/templates/aboutUs.html | 27 + Vishal/templates/analysisForm.html | 67 + Vishal/templates/analysisReport.html | 94 + Vishal/templates/decrypt.html | 99 + Vishal/templates/done.html | 68 + Vishal/templates/encrypt.html | 76 + Vishal/templates/index.html | 28 + Vishal/templates/layout.html | 92 + Vishal/templates/multipleAnalysisReport.html | 94 + Vishal/templates/try.html | 16 + Vishal/templates/vishal.html | 16 + __pycache__/aesutil.cpython-38.pyc | Bin 0 -> 2839 bytes __pycache__/aesutil.cpython-39.pyc | Bin 0 -> 2833 bytes __pycache__/rsautil1.cpython-38.pyc | Bin 0 -> 1125 bytes __pycache__/rsautil1.cpython-39.pyc | Bin 0 -> 1119 bytes app.py | 57 + car.jpeg | Bin 0 -> 9594 bytes cover.mp4 | Bin 0 -> 785302 bytes data.jpeg | Bin 0 -> 13244 bytes decodeaudio.py | 231 + decodeimage.py | 239 + decodemulitpleformat.py | 407 + decodetext.py | 205 + encode.py | 405 +- hide.mp4 | Bin 0 -> 202920 bytes keys/note.md | 2 + keys/private_key_5000.pem | 62 + keys/public_key_5000.pem | 1 + new_encode_decode_files/decode.py | 319 + new_encode_decode_files/encode.py | 581 + psnr.py | 21 + rsagen.py | 2 +- speech.wav | 0 static/assets/favicon.ico | Bin 0 -> 23462 bytes static/css/bootstrap.min.css | 6 + static/css/style.css | 125 + static/css/styles.css | 11248 +++++++++++++++++ templates/aboutUs.html | 20 + templates/analysisForm.html | 67 + templates/analysisReport.html | 94 + templates/decrypt.html | 99 + templates/done.html | 68 + templates/encrypt.html | 84 + templates/index.html | 28 + templates/layout.html | 92 + templates/multipleAnalysisReport.html | 94 + templates/try.html | 16 + templates/vishal.html | 16 + test.jpg | Bin 0 -> 15294 bytes vishal.txt | 1 + 69 files changed, 29287 insertions(+), 48 deletions(-) create mode 100644 AES-ENC-Key/ReceiverKey.txt create mode 100644 AES-ENC-Key/note.md create mode 100644 Backup Files/app.py create mode 100644 Backup Files/decode.py create mode 100644 Backup Files/encode.py create mode 100644 Backup Files/encrypt.html create mode 100644 DecodeVideo.py create mode 100644 Message.txt create mode 100644 SECURITY.md create mode 100644 Vishal/app.py create mode 100644 Vishal/decode.py create mode 100644 Vishal/encode.py create mode 100644 Vishal/static/assets/favicon.ico create mode 100644 Vishal/static/css/bootstrap.min.css create mode 100644 Vishal/static/css/style.css create mode 100644 Vishal/static/css/styles.css create mode 100644 Vishal/static/images/1.jpeg create mode 100644 Vishal/static/images/coded-data.gif create mode 100644 Vishal/templates/aboutUs.html create mode 100644 Vishal/templates/analysisForm.html create mode 100644 Vishal/templates/analysisReport.html create mode 100644 Vishal/templates/decrypt.html create mode 100644 Vishal/templates/done.html create mode 100644 Vishal/templates/encrypt.html create mode 100644 Vishal/templates/index.html create mode 100644 Vishal/templates/layout.html create mode 100644 Vishal/templates/multipleAnalysisReport.html create mode 100644 Vishal/templates/try.html create mode 100644 Vishal/templates/vishal.html create mode 100644 __pycache__/aesutil.cpython-38.pyc create mode 100644 __pycache__/aesutil.cpython-39.pyc create mode 100644 __pycache__/rsautil1.cpython-38.pyc create mode 100644 __pycache__/rsautil1.cpython-39.pyc create mode 100644 app.py create mode 100644 car.jpeg create mode 100644 cover.mp4 create mode 100644 data.jpeg create mode 100644 decodeaudio.py create mode 100644 decodeimage.py create mode 100644 decodemulitpleformat.py create mode 100644 decodetext.py create mode 100644 hide.mp4 create mode 100644 keys/note.md create mode 100644 keys/private_key_5000.pem create mode 100644 keys/public_key_5000.pem create mode 100644 new_encode_decode_files/decode.py create mode 100644 new_encode_decode_files/encode.py create mode 100644 psnr.py create mode 100644 speech.wav create mode 100644 static/assets/favicon.ico create mode 100644 static/css/bootstrap.min.css create mode 100644 static/css/style.css create mode 100644 static/css/styles.css create mode 100644 templates/aboutUs.html create mode 100644 templates/analysisForm.html create mode 100644 templates/analysisReport.html create mode 100644 templates/decrypt.html create mode 100644 templates/done.html create mode 100644 templates/encrypt.html create mode 100644 templates/index.html create mode 100644 templates/layout.html create mode 100644 templates/multipleAnalysisReport.html create mode 100644 templates/try.html create mode 100644 templates/vishal.html create mode 100644 test.jpg create mode 100644 vishal.txt diff --git a/AES-ENC-Key/ReceiverKey.txt b/AES-ENC-Key/ReceiverKey.txt new file mode 100644 index 0000000..a0ed95d --- /dev/null +++ b/AES-ENC-Key/ReceiverKey.txt @@ -0,0 +1 @@ +iqRiuIjjJdY83yHjYxkdYkbtBNCWbwdtsdKIxfoGUHrYyHlopgQYnbphTc6qVRI6N0fSh/cKG5XzuZCAsGITashg4/hANg8bzc4ifZAR7DVi/wRBuNwBgFHaW50GslqYx6f7Bzxog5sSOZkeCl9LQ8Qyv3aOwFnupsrTh23DaCibajG0qET7V4pgEsBrZf8Mwhu7hE+R3hbCMHMJn17AdJUbWzxMgwA4LOO6YkS4eeTIMAlODDeTFECYNPZuupCEJ+No5bG5FJPsRxTvbXa8RltCwWcRvnZ06Olgs/YK0Op1zI4F5KHkSJe2dWM95bjv+49KajjLLVbzmw71vfVnqF7LiohtwryAnIQJHw2HY4dgXpJo6zSe3tLwHkxFVsegbhUMdaXfh575VZLADIOumLBsVelhbRq37CfXyr8EvBNPZfuidiiJ8FMo2a2F041AUmmHIJkZflJPSEdOmbtsOAow0gKEYdUbeeyljqJ233mancffOX28zr8U9oUIiZWfe9/F4otB5+ypTUgtb5GFP4XdexOzvP+l6cvqHQfBTvFDcljP3zolJmAJQyi15egZQmK8QXlT4n0fhJUiZPrAIlW58Tjk5XuByLK0awkC1CBCtE4vkb8H+vPA4/6XOVWNgS+p5wB2CLeXA4CphQwAP8mOCpjrQYl5KkEn2I3voNNZpOBKDm/sx8coLfYE4kEf8+4SOC0NCeneXOyO8H8oUPQ8q3+7GpmnsoGCAMOC5us80vPFG5VW653SzvMOWsoxdcrQrfONZaCka5NIj8GAuCaH1/CtRC2PXsQWvDDTVcKXTkgqD6grF/RN5eQqDs7cLg== \ No newline at end of file diff --git a/AES-ENC-Key/note.md b/AES-ENC-Key/note.md new file mode 100644 index 0000000..6e19fdf --- /dev/null +++ b/AES-ENC-Key/note.md @@ -0,0 +1,2 @@ +RSA Encrypted AES key will be stored in this folder. Share the key text to receiver to decrypt. +DO NOT DELETE THIS FOLDER. diff --git a/Backup Files/app.py b/Backup Files/app.py new file mode 100644 index 0000000..154d9d5 --- /dev/null +++ b/Backup Files/app.py @@ -0,0 +1,65 @@ +from flask import Flask,render_template,request,flash +from encode import * +from decode import * + +app=Flask(__name__) + +app.config['SECRET_KEY'] = '12345' +@app.route('/') +def index(): + return render_template('index.html') + +@app.route('/decrypt') +def decrypt(): + return render_template('decrypt.html') + +@app.route('/encrypt') +def Analysis(): + # innn name get from analysisForm.html + name="Vishal Mankotia" + n="Govindani" + print(name) + return render_template('./encrypt.html',name=name,n=n) + +@app.route('/aboutus') +def About(): + return render_template('aboutUs.html') + +@app.route('/encode', methods=['POST','GET']) +def encode(): + result = request.form.to_dict() + cover = result['cover'] + to_hide1 = result['to_hide1'] + + file_type = result['file_type'] + print(type(file_type)) + # a=input("Enter the file type: ") + encode_method1=result['encode_method'] + if(file_type=='5'): + to_hide2=result['to_hide2'] + to_hide3=result['to_hide3'] + to_hide4=result['to_hide4'] + multi(cover,to_hide1,to_hide2,to_hide3,to_hide4,file_type,encode_method1) + else: + final(cover,to_hide1,file_type,encode_method1) + print(cover,to_hide1,file_type) + + a=1 + + return render_template('decrypt.html',set=a) + +@app.route('/decode', methods=['POST','GET']) +def decode(): + result=request.form.to_dict() + to_decode=result["to_decode"] + decode_method=result["decode_method"] + print(to_decode,decode_method) + + message=decrypt_file(to_decode,decode_method) + + + return render_template('done.html',message=message) + + + +app.run(debug=True) \ No newline at end of file diff --git a/Backup Files/decode.py b/Backup Files/decode.py new file mode 100644 index 0000000..4a7131a --- /dev/null +++ b/Backup Files/decode.py @@ -0,0 +1,440 @@ + +##This File for Text and text Document read +from stegano import lsb +from time import * +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 + +def decrypt_file(file,method): + global to_decrypt + to_decrypt=file + + global decode_method + decode_method=method + + global FRAMES + + global Encryption_Style + global decoded + + 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']) + global ENCODED_VIDEO + ENCODED_VIDEO = to_decrypt + global temp_folder + temp_folder = "tmp2" + # frame_choice = int(input("1) Extract and enter frame numbers from image \n2) Enter frame numbers manually : \nEnter choice: ")) + frame_choice=1 + decoded = {} + + if frame_choice == 1: + ENCODED_IMAGE = "image-enc.png" + 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(1) + if Encryption_Style == 1: + key = "VtCWNhhO8tB96CK2Xso13YtaHndt0j37vp9czIGEQ5QfxwOsQm2xThqPOUFN58inisxiU4iJPykAw0q+6Nrtl3hAXN5oauKq8ukZJGZDvv7J7sLnyhoEWwAi2NJyZLmSq8VkTrTW0t9DfWCszF6vmxQMb/zyWC56/i4CjFj99SHX5M5bKqvzI2ljKTfltdrJVZTabBemcQaVDmv+1G0QmQsfOL/z4wso3vb4L7JUv/Mk6zwiAc9dRDi/KVOYQaS7q+weyBmpbGbn4xPuMfEDpwprCCOAbGLBdDYtGQwUTmy8NBMMN8yyg2t0hFjXHOSUm4HCsv0AEhq+bviaUhtpYf2cCTXH5HFeLB6TDnhCfTqQQ3C1dMqvUmRPNLAyG8LPCNjFKShR8MLsCBs5uPM4EXl+l1YpN5hxjYorXFQHF3yK4VS0O9WJO2WWTHch6sh7DKSq2onlzgWvgP38K020Tx4ZeIiNSslM/NopvT/F7YN2E5X0EYrap6tJq09fcz7HwnbBGkYnRTPzS+uR0/Q95biMJOzZ2sqOu1nqpDTGYr+dlXR5h4aNy1Eu/vkj4ALkq4WFVUvMCtLlcBvtfdaTQwkOpd+6Avy0g7WDQ5kCu/mEfOOrZKeouU5p0vf5cXPyxx4lb/+Dw+6xgU5iMI3CwwJLNb4EW3m0dku56ln6iydHg9NRaM4bDJC0pVJgUyCtTxhCsXZ2UOwHzUJdk+WMg9tcz1UCgx7JBMGZjSpOWLG5X9k0Aa+UKGA17lQ1phJyzs0mdfB5EvFFThNu3qeWSWx3BUjJPIHml1OaABh3GfwO30JiWkHtSBg/47080x9aRg==" + key_rsa = rsautil1.decrypt(message=key) + key_rsa = key_rsa.decode('utf-8') + print(f"Asymetric decrypted key \n {key_rsa}") + key123=int(2) + key = '1' + if key123==1: + msg = aesutil.decrypt(key=key,source=res) + msg1 = msg.decode('utf-8') + cprint(f"Decoded image : \n {msg}",'green') + # print the msg in the terminal + # print("The type ",type(msg)) + # a=input("halt") + # print("The type ",msg) + # a=input("halt") + # print("The type 1",type(msg1)) + # a=input("halt") + print("The type 1",msg1) + a=input("halt") + print("Visha") + + + FRAMES = list(map(int, input("Enter Above FRAME NUMBERS seperated by space: ").split())) + + else: + msg = aesutil.decrypt(key=key,source=res,keyType='ascii') + print(type(msg)) + print(msg) + print(list(msg)) + li=[] + count=0 + for i in msg: + if(i<=57 and i>47): + + li.append(i-48) + print(li) + + k=0 + lis=[] + # [76, 85, 14, 81, 95, 68, 97, 65, 51, 59, 16, 98, 60, 33, 49] + for i in range(0,int(len(li)),2): + lis.append(li[i]*10+li[i+1]) + + print(lis) + + print(type(lis[0])) + + + + + + + + msg1 = msg.decode('utf-8') + cprint(f"Decoded image: \n {msg1}",'green') + + print(type(msg1)) + print(msg1) + li=list(msg1) + print(li) + print(type(li)) + + + + + + FRAMES = lis + # 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') + # print the msg in the terminal + print("The type ",type(msg)) + # a=input("halt") + # print("The type ",msg) + # a=input("halt") + # print("The type 1",type(msg1)) + # a=input("halt") + # print("The type 1",msg1) + # a=input("halt") + # print("Visha") + FRAMES = list(map(int, input("Enter Above FRAME NUMBERS seperated by space: ").split())) + + + else : + + + FRAMES = [i for i in range(1,16)] + cprint("Select your decryption type \n 1) AES Encrypted {Symetric Encryption} \n 2) RSA Encrypted {Assysmetric Encryption}",'blue') + Encryption_Style=int(decode_method) + #print(FRAMES) + createTmp() + frames = countFrames() + decodeVideo(frames) + return arrangeAndDecrypt() +# pip3 install gTTS pyttsx3 +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: + + while(True): + try: + for fn in FRAMES: + if(decoded[fn]==None): + break + res = res + decoded[fn] + + break + except: + FRAMES.pop(-1) + print(len(FRAMES)) + print(res) + # A=input("Enter the key to decrypt image : ") + cprint(f"Final string: {res}",'green') + key123=int(2) + key = '1' + if key123==1: + + msg = aesutil.decrypt(key=key,source=res) + msg1 = msg.decode('utf-8') + + + cprint(f"Decoded message: \n {msg}",'green') + print(1) + clean_tmp() + else: + msg = aesutil.decrypt(key=key,source=res,keyType='ascii') + print(msg) + # a=input("dfj") + msg1 = msg.decode('utf-8') + print(msg1) + + + if(msg1[-1]=='2'): + s=msg1[:-1] + + print(s) + s="Your text document Output is \n\n"+s + return s + + elif(msg1[-1]=='3'): + + s=msg1[:-7] + r=int(msg1[-7:-4]) + co=int(msg1[-4:-1]) + print(r,co) + print(type(r)) + + li=s.split(" ") + result=[] + a=[] + b=[] + + c=0 + print(len(li)) + for i in range(r): + + for j in range(co): + for k in range(3): + b.append(int(li[c])) + c+=1 + a.append(b) + b=[] + result.append(a) + a=[] + print(c) + result=np.asarray(result) + # print(result.shape) + result=result.astype(np.uint8) + print(result.shape) + print(type(result)) + cv2.imshow('Hidden Image',result) + print("Wait until Image Opens!!") + + cv2.waitKey(0) + + return "Image successfully decoded and displayed" + + + + + elif(msg1[-1]=='4'): + s=msg1[:-1] + print(s) + myobj = gTTS(text=s, lang='en', slow=False) + myobj.save("output.mp3") + print("Audio Successful Decoded from Video") + # Playing the converted file + playsound('output.mp3') + return "Audio successfully decoded and played "+s + + + elif(msg1[-1]=='6'): + r=int(msg1[-7:-4]) + co=int(msg1[-4:-1]) + s=msg1[:-7] + + + li=s.split(" ") + c=0 + + while(c "+pandu[0]+" Your Audio is => "+pandu[1] + + + + + + + + # cprint(f"Decoded message: \n {msg1}",'red') + # msg1.save("output.mp3") + print(2) + # 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() + diff --git a/Backup Files/encode.py b/Backup Files/encode.py new file mode 100644 index 0000000..f4dfd82 --- /dev/null +++ b/Backup Files/encode.py @@ -0,0 +1,632 @@ + + + +from tkinter import filedialog +from tkinter import * +from stegano import lsb +import speech_recognition as sr +import cv2 +import math +import os +import shutil +from time import * +from subprocess import call,STDOUT +import aesutil +import sys +from termcolor import cprint +from pyfiglet import figlet_format +import rsautil1 +import base64 +import PIL.Image as PILImage +from simple_colors import * +import time +from tkinter.filedialog import askopenfile +from gtts import gTTS +import random + + +# Used to split string into parts. +def split_string(s_str,count=15): + per_c=math.ceil(len(s_str)/count) + c_cout=0 + out_str='' + split_list=[] + for s in s_str: + out_str+=s + c_cout+=1 + if c_cout == per_c: + split_list.append(out_str) + out_str='' + c_cout=0 + if c_cout!=0: + split_list.append(out_str) + return split_list + +# Used to count frames in Video +def countFrames(): + cap = cv2.VideoCapture(f_name) + length = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) + cprint(f"Total frame in video are : {length-1}",'blue') + return length + +# Extract the frames +def frame_extraction(video): + if not os.path.exists("./tmp"): + os.makedirs("tmp") + temp_folder="./tmp" + cprint("[INFO] tmp directory is created",'green') + vidcap = cv2.VideoCapture(video) + count = 0 + cprint("[INFO] Extracting frames from video \n Please be patient",'blue') + while True: + success, image = vidcap.read() + if not success: + break + cv2.imwrite(os.path.join(temp_folder, "{:d}.png".format(count)), image) + count += 1 + cprint("[INFO] All frames are extracted from video",'green') + +#Encrypt and encode text into frames +def encode_string(input_string,root="./tmp/"): + cprint("Select your encryption type \n 1) AES Encrypted {Symetric Encryption} \n 2) RSA Encrypted {Assysmetric Encryption}\n",'blue') + Encryption_Style=int(encode_method) + if Encryption_Style == 1: + res=input_string + key123=int(2) + key = "1" + if key123==1: + input_string = aesutil.encrypt(key=key,source=res) + else: + input_string = aesutil.encrypt(key=key,source=res,keyType='ascii') + key_path = "./keys/public_key_5000.pem" + key_rsa = rsautil1.encrypt(message=key,key_path=key_path) + key_rsa = key_rsa.decode('utf-8') + print(f"Asymetric encrypted key to be shared with receiver \n {key_rsa}") + file_obj = open("./AES-ENC-Key/ReceiverKey.txt", "wb") + key_rsa = key_rsa.encode() + file_obj.write(key_rsa) + file_obj.close() + print(f"\n AES Encypted message: {input_string}") + split_string_list=split_string(input_string) + #print(split_string_list) + split_string_length = len(split_string_list) + + li=[] + while(len(li)!=split_string_length): + + num=random.randint(10,99) + + if(num not in li): + + li.append(num) + print(li) + # FRAMES = [random.randint(10,100) for i in range (1,split_string_length+1)] + FRAMES = li + + # frame_choice = int(input("1) Do you want to store frame numbers in an image \n 2) No! Don't store : ")) + frame_choice = 1 + if frame_choice == 1: + ENCODE_IMAGE = "test.jpg" + res = str(FRAMES) + if key123==1: + FRAMES_ENCODED = aesutil.encrypt(key=key,source=res) + secret = lsb.hide(ENCODE_IMAGE,str(FRAMES_ENCODED)) + secret.save("image-enc.png") + cprint("[Info] Frames numbers are hidden inside the image with filename image-enc.png",'red') + else: + FRAMES_ENCODED = aesutil.encrypt(key=key,source=res,keyType='ascii') + secret = lsb.hide(ENCODE_IMAGE,str(FRAMES_ENCODED)) + secret.save("image-enc.png") + cprint("[Info] Frames numbers are hidden inside the image with filename image-enc.png",'red') + else : + cprint("[Info] Frame numbers are not stored anywhere. Please remember them.",'red') + else : + res=input_string + key_path = "./keys/public_key_5000.pem" + input_string = rsautil1.encrypt(message=res,key_path=key_path) + input_string = input_string.decode('utf-8') + input_string = str(input_string) + print(f"Encypted message: \n {input_string}") + split_string_list=split_string(input_string) + #print(split_string_list) + split_string_length = len(split_string_list) + FRAMES = [i for i in range(1,16)] + # frame_choice = int(input("1) Do you want to store frame numbers in an image \n2) No! Don't store : ")) + frame_choice = 2 + if frame_choice == 1: + ENCODE_IMAGE = input("Enter image name with extension : ") + res = str(FRAMES) + FRAMES_ENCODED = rsautil1.encrypt(message=res,key_path=key_path) + FRAMES_ENCODED = FRAMES_ENCODED.decode('utf-8') + secret = lsb.hide(ENCODE_IMAGE,str(FRAMES_ENCODED)) + secret.save("image-enc.png") + cprint("[Info] Frames numbers are hidden inside the image with filename image-enc.png",'red') + #res = lsb.reveal("image-enc.png") #for debugging + #res = res.decode('utf-8') + #res = str(res) + #print(f"Encrypted frame numbers : {res}") + else : + cprint("[Info] Frame numbers are not stored anywhere. Please remember them.",'red') + + for i in range(0,len(FRAMES)): + f_name="{}{}.png".format(root,FRAMES[i]) + #print(f_name) + secret_enc=lsb.hide(f_name,split_string_list[i]) + secret_enc.save(f_name) + cprint("[INFO] Frame {} holds {}".format(FRAMES[i],split_string_list[i]),'blue') + +# delete temporary files +def clean_tmp(path="./tmp"): + if os.path.exists(path): + shutil.rmtree(path) + print("[INFO] tmp files are cleaned up") +def main(): + ENCODE_CHOICE = int(file_type1) + print("inside main") + + # ENCODE_CHOICE = int(input("Choose text or text from text document to hide inside image. \n Enter number either 1|2|3|4|5 : \n1.TEXT \n2.TEXT DOCUMENT \nEnter Your Choice : ")) + # print("Enter Your Choice : ") + + if ENCODE_CHOICE==1: + TEXT_TO_ENCODE = input("Enter the text to encrypt and encode : ") + countFrames() + frame_extraction(f_name) + encode_string(TEXT_TO_ENCODE) + # Mix images into video and add audio. + call(["ffmpeg", "-i",f_name, "-q:a", "0", "-map", "a", "tmp/audio.mp3", "-y"],stdout=open(os.devnull, "w"), stderr=STDOUT) + call(["ffmpeg", "-i", "tmp/%d.png" , "-vcodec", "png", "tmp/video.mov", "-y"],stdout=open(os.devnull, "w"), stderr=STDOUT) + call(["ffmpeg", "-i", "tmp/video.mov", "-i", "tmp/audio.mp3", "-codec", "copy", "video.mov", "-y"],stdout=open(os.devnull, "w"), stderr=STDOUT) + + cprint("Video is succesfully encoded with encrypted text.",'green') + clean_tmp() + if ENCODE_CHOICE==2: + print("Please Select a Txt file as an Input") + # FILE_TO_ENCODE = filedialog.askopenfilename(initialdir = "/",title = "Select file",filetypes = (("Text files","*.txt"),("all files","*.*"))) + FILE_TO_ENCODE= to_hide1 + + # FILE_TO_ENCODE = input("Select text from file:") + TEXT_TO_ENCODE = [] + with open(FILE_TO_ENCODE) as f: + for lines in f: + TEXT_TO_ENCODE.append(lines) + TEXT_TO_ENCODE = str(TEXT_TO_ENCODE) + print(TEXT_TO_ENCODE) + TEXT_TO_ENCODE+="2" + countFrames() + frame_extraction(f_name) + encode_string(TEXT_TO_ENCODE) + # Mix images into video and add audio. + call(["ffmpeg", "-i",f_name, "-q:a", "0", "-map", "a", "tmp/audio.mp3", "-y"],stdout=open(os.devnull, "w"), stderr=STDOUT) + call(["ffmpeg", "-i", "tmp/%d.png" , "-vcodec", "png", "tmp/video.mov", "-y"],stdout=open(os.devnull, "w"), stderr=STDOUT) + call(["ffmpeg", "-i", "tmp/video.mov", "-i", "tmp/audio.mp3", "-codec", "copy", "video.mov", "-y"],stdout=open(os.devnull, "w"), stderr=STDOUT) + print(yellow('Video is succesfully encoded with encrypted text Document', ['bold'])) + # cprint("Video is succesfully encoded with encrypted text.",'yellow') + clean_tmp() + + if ENCODE_CHOICE==3: + # root=Tk() + FILE_TO_ENCODE= to_hide1 + # FILE_TO_ENCODE = filedialog.askopenfilename(initialdir = "/",title = "Select file",filetypes = (("Image files","*.*"),("all files","*.*"))) + + + img=cv2.imread(FILE_TO_ENCODE) + # img=cv2.resize(img,(1000,1000)) + li=[] + + # cv2.imshow("img",img) + # root.destroy() + # root.mainloop() + # .deiconify() + # print("Hello") + # cv2.waitKey(0) + # print("Hello2") + # root.mainloop() + for i in img: + for j in i: + for k in j: + li.append(k) + + + s=" ".join(str(x) for x in li) + a,b,c=img.shape + s+=str(a)+str(b)+"3" + # print(s) + countFrames() + frame_extraction(f_name) + encode_string(s) + # Mix images into video and add audio. + call(["ffmpeg", "-i",f_name, "-q:a", "0", "-map", "a", "tmp/audio.mp3", "-y"],stdout=open(os.devnull, "w"), stderr=STDOUT) + call(["ffmpeg", "-i", "tmp/%d.png" , "-vcodec", "png", "tmp/video.mov", "-y"],stdout=open(os.devnull, "w"), stderr=STDOUT) + call(["ffmpeg", "-i", "tmp/video.mov", "-i", "tmp/audio.mp3", "-codec", "copy", "video.mov", "-y"],stdout=open(os.devnull, "w"), stderr=STDOUT) + print(yellow('Video is succesfully encoded with Image.', ['bold'])) + # cprint("Video is succesfully encoded with encrypted text.",'yellow') + clean_tmp() + + if ENCODE_CHOICE==4: + r=sr.Recognizer() + # print("1") + print(yellow('Audio Name Speech.wav is reading...', ['bold'])) + with sr.AudioFile(to_hide1) as source: + + audio_text = r.listen(source) + print(audio_text) + # print("1") + try: + text = r.recognize_google(audio_text) + # print('Converting audio transcripts into text ...') + print(text) + except: + print('Sorry.. run again...') + + text+="4" + countFrames() + frame_extraction(f_name) + encode_string(text) + # print("Hurreg") + # Mix images into video and add audio. + call(["ffmpeg", "-i",f_name, "-q:a", "0", "-map", "a", "tmp/audio.mp3", "-y"],stdout=open(os.devnull, "w"), stderr=STDOUT) + call(["ffmpeg", "-i", "tmp/%d.png" , "-vcodec", "png", "tmp/video.mov", "-y"],stdout=open(os.devnull, "w"), stderr=STDOUT) + call(["ffmpeg", "-i", "tmp/video.mov", "-i", "tmp/audio.mp3", "-codec", "copy", "video.mov", "-y"],stdout=open(os.devnull, "w"), stderr=STDOUT) + + cprint("Video is succesfully encoded with encrypted audio.",'green') + clean_tmp() + + + + + if ENCODE_CHOICE==5: + print(yellow('Be Patient for processing ', ['bold'])) + # print("Be Patient for processing") + # vishal =Tk() + FILE_TO_ENCODE= f1 + + # FILE_TO_ENCODE = input("Select text from file:") + TEXT_TO_ENCODE = [] + with open(FILE_TO_ENCODE) as f: + for lines in f: + TEXT_TO_ENCODE.append(lines) + TEXT_TO_ENCODE = str(TEXT_TO_ENCODE) + print(TEXT_TO_ENCODE) + + text1=TEXT_TO_ENCODE + + + # time.sleep(2) + # print(yellow('The text Entered is ', ['bold'],text1)) + path = f2 + + + + + r=sr.Recognizer() + # # print("1") + # print(yellow('Audio Name Speech.wav is reading...', ['bold'])) + with sr.AudioFile(path) as source: + + audio_text = r.listen(source) + # print("1") + try: + text2 = r.recognize_google(audio_text) + # print('Converting audio transcripts into text ...') + + print(text2) + except: + print('Sorry.. run again...') + print("\n") + # time.sleep(2) + path= f3 + + + + img=cv2.imread(path) + img=cv2.resize(img,(168,200)) + li=[] + # a,b,c=img.shape + + for i in img: + for j in i: + for k in j: + li.append(k) + + + text3=" ".join(str(x) for x in li) + + print("\n\n") + # time.sleep(2) + path= f4 + + + cap = cv2.VideoCapture(path) + length = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) + li=[] + count=0 + + while(cap.isOpened()): + + ret, frame = cap.read() + if ret == True: + frame = cv2.resize(frame, (100, 100)) + # cv2.imshow('frame',frame) + # count+=1 + # if(count%2==0): + + # fp+=1 + # for i in frame: + + # for j in i: + # for k in j: + # li.append(k) + + count+=1 + if(count%48==0): + # 4 lakh + + + # fp+=1 + for i in frame: + + for j in i: + for k in j: + li.append(k) + + if cv2.waitKey(10) & 0xFF == ord('q'): + break + else: + break + text4=" ".join(str(x) for x in li) + # input() + print(text1) + sleep(1) + print(text2) + sleep(1) + print(text3) + sleep(1) + print(text4) + print("\n\n") + time.sleep(2) + s=text1+"***"+text2+"***"+text3+"***"+text4 +# 1 89 32 2 5 6 7 8 9 10 11 12 13 14 18 +# 89 32 2 5 6 7 8 9 10 11 12 13 14 18 1 +#./keys/public_key_5000.pem + # Prajwal Hitashri Nupur Vishal Sameer are the Members of group 9 + # r=sr.Recognizer() + # # print("1") + # print(yellow('Audio Name Speech.wav is reading...', ['bold'])) + # with sr.AudioFile('speech.wav') as source: + + # audio_text = r.listen(source) + # # print("1") + # try: + # text = r.recognize_google(audio_text) + # # print('Converting audio transcripts into text ...') + # print(text) + # except: + # print('Sorry.. run again...') + + + countFrames() + frame_extraction(f_name) + encode_string(s) + # print("Hurreg") + # Mix images into video and add audio. + call(["ffmpeg", "-i",f_name, "-q:a", "0", "-map", "a", "tmp/audio.mp3", "-y"],stdout=open(os.devnull, "w"), stderr=STDOUT) + call(["ffmpeg", "-i", "tmp/%d.png" , "-vcodec", "png", "tmp/video.mov", "-y"],stdout=open(os.devnull, "w"), stderr=STDOUT) + call(["ffmpeg", "-i", "tmp/video.mov", "-i", "tmp/audio.mp3", "-codec", "copy", "video.mov", "-y"],stdout=open(os.devnull, "w"), stderr=STDOUT) + + cprint("Video is succesfully encoded with Multiple formats data .",'green') + clean_tmp() + + + + + # FILE_TO_ENCODE= input("\n Enter image name with extension : ") + # FILE_TO_ENCODE = filedialog.askopenfilename(initialdir = "/",title = "Select file",filetypes = (("Image files","*.*"),("all files","*.*"))) + + # # print("Succ") + # # Language in which you want to convert + # language = 'en' + # myobj = gTTS(text=FILE_TO_ENCODE, lang=language, slow=False) + # print("Succ1") + # # img=cv2.imread(FILE_TO_ENCODE) + # # Saving the converted audio in a mp3 file named + # # welcome + # myobj.save("welcome1.mp3") + # print("Succ2") + + # Playing the converted file + # os.system("welcome.mp3") + # r = sr.Recognizer() + # with sr.AudioFile('spech.wav') as source: + + + # audio_text = r.listen(source) + # # recoginize_() method will throw a request error if the API is unreachable, hence using exception handling + # try: + + + # using google speech recognition + # text = r.recognize_google(audio_text) + # print('Converting audio transcripts into text ...') + # print(text) + # if ENCODE_CHOICE==6: + # print("Be Patient for processing") + + # text1 = input("1.enter text to hide\n") + # print("Select file to hide audio") + # file = askopenfile(parent=vishal, mode='r+', title = "ADD DATA",filetype=[("audio file",".wav"),("ALL FILES", ".*")]) + + # r=sr.Recognizer() + # # print("1") + # print(yellow('Audio Name Speech.wav is reading...', ['bold'])) + # with sr.AudioFile(file.name) as source: + + # audio_text = r.listen(source) + # # print("1") + # try: + # text2 = r.recognize_google(audio_text) + # # print('Converting audio transcripts into text ...') + # print(text2) + + # countFrames() + # frame_extraction(f_name) + # encode_string(s) + # print("Hurreg") + if ENCODE_CHOICE==6: + print("Be Patient for processing") + + cap = cv2.VideoCapture(to_hide1) + length = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) + li=[] + count=0 + + while(cap.isOpened()): + + ret, frame = cap.read() + if ret == True: + frame = cv2.resize(frame, (150, 150)) + # cv2.imshow('frame',frame) + # count+=1 + # if(count%2==0): + + # fp+=1 + # for i in frame: + + # for j in i: + # for k in j: + # li.append(k) + + count+=1 + if(count%48==0): + # 4 lakh + + + # fp+=1 + for i in frame: + + for j in i: + for k in j: + li.append(k) + a,b,c=frame.shape + + if cv2.waitKey(10) & 0xFF == ord('q'): + break + else: + break + s=" ".join(str(x) for x in li) + s+=str(a)+str(b)+"6" + + # r=sr.Recognizer() + # # print("1") + # print(yellow('Audio Name Speech.wav is reading...', ['bold'])) + # with sr.AudioFile('speech.wav') as source: + + # audio_text = r.listen(source) + # # print("1") + # try: + # text = r.recognize_google(audio_text) + # # print('Converting audio transcripts into text ...') + # print(text) + # except: + # print('Sorry.. run again...') + + + countFrames() + frame_extraction(f_name) + encode_string(s) + # print("Hurreg") + # Mix images into video and add audio. + call(["ffmpeg", "-i",f_name, "-q:a", "0", "-map", "a", "tmp/audio.mp3", "-y"],stdout=open(os.devnull, "w"), stderr=STDOUT) + call(["ffmpeg", "-i", "tmp/%d.png" , "-vcodec", "png", "tmp/video.mov", "-y"],stdout=open(os.devnull, "w"), stderr=STDOUT) + call(["ffmpeg", "-i", "tmp/video.mov", "-i", "tmp/audio.mp3", "-codec", "copy", "video.mov", "-y"],stdout=open(os.devnull, "w"), stderr=STDOUT) + + cprint("Video is succesfully encoded with encrypted Video.",'green') + clean_tmp() + + + + +def multi(cover,to_hide1,to_hide2,to_hide3,to_hide4,file_type,encode_method1): + print("name is ",cover) + print("to_hide is ",to_hide1) + print("to_hide is ",to_hide2) + print("to_hide is ",to_hide3) + print("to_hide is ",to_hide4) + print("file_type is ",file_type) + global f_name + f_name = cover + global f1 + f1 = to_hide1 + global f2 + f2 = to_hide2 + global f3 + f3 = to_hide3 + global f4 + f4 = to_hide4 + global file_type1 + file_type1 = file_type + global encode_method + encode_method = encode_method1 + + print("encode_method is ",end="") + if(encode_method=='1'): + print("AES") + else: + print("RSA") + main() + + + + + +def final(name,to_hide,file_type,encode_method1): + # os.system('cls' if os.name == 'nt' else 'clea/r') + print("name is ",name) + print("to_hide is ",to_hide) + print("file_type is ",file_type) + + global name1 + name1 = name + global to_hide1 + to_hide1 = to_hide + global file_type1 + file_type1 = file_type + global encode_method + encode_method = encode_method1 + print("name is ",name1) + print("to_hide is ",to_hide1) + print("file_type is ",file_type1) + print("encode_method is ",end="") + if(encode_method=='1'): + print("AES") + else: + print("RSA") + print(type(file_type1)) + + cprint(figlet_format('Group6', font='slant'),'yellow', attrs=['bold']) + # time.sleep(3) + # print("\n") + + + # print(green('Guide: Prof. (Dr.) Premanand P. Ghadekar', ['bold'])) + # print("Guide: Prof. (Dr.) Premanand P. Ghadekar") + # time.sleep(2) + + print("\n") + # 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) + print(yellow('Video Steganography', ['bold'])) + print("\n\n") + cprint(figlet_format('AES & RSA encrytion', font='digital'),'green', attrs=['bold']) + global f_name + f_name = name + #image_name = sys.argv[2] + main() diff --git a/Backup Files/encrypt.html b/Backup Files/encrypt.html new file mode 100644 index 0000000..5c261ea --- /dev/null +++ b/Backup Files/encrypt.html @@ -0,0 +1,121 @@ +{% extends 'layout.html' %} + +{% block body %} + +
+
+
+ + + +

Video Stegnography

+

Using AES and RSA

+
+ + + + +
+ + +
+ + + +
+
+ + + + +
+ + +
+ +
+ + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+ + + + + + +
+
+
+ +
+ +
+ + + +
+ + +{% endblock %} \ No newline at end of file diff --git a/DecodeVideo.py b/DecodeVideo.py new file mode 100644 index 0000000..6ab705a --- /dev/null +++ b/DecodeVideo.py @@ -0,0 +1,197 @@ +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 +##This File for Text and text Document read + +os.system('cls' if os.name == 'nt' else 'clear') +cprint(figlet_format('Group9', font='slant'),'green', attrs=['bold']) +print(yellow('Video Steganography', ['bold'])) +# cprint(figlet_format('AES & RSA encrypted Video Steganography Decode(Group9)', font='digital'),'blue', attrs=['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() + print(type(s)) + a=input("Enter to play Video") + li=s.split(" ") + # print(len(li)) + c=0 + while(c