Priyansh-15 / Steganography-Tools

A project named "STEGANOGRAPHY TOOLS " that provide 4 types of Steganography { Image, Text, Audio, Video } that hides User's Text message in the desired cover file using the tool and can send it to the receiver who can extract the Hidden message using the same tool .
https://github.com/Spidy-PS/Steganography-Tools
68 stars 24 forks source link

Issue in Image Encode Function #2

Closed shivampatel0902 closed 2 years ago

shivampatel0902 commented 2 years ago

img encode was sucessful but in img decode was not show.. show in img continue run but no show any error or ouput.. please help us..

image

Priyansh-15 commented 2 years ago

try saving the encoded image in .png format

shivampatel0902 commented 2 years ago

i am trying with png but not solve a problem .. please help this project i can choose in my college..

[image: Mailtrack] https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality11& Sender notified by Mailtrack https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality11& 12/06/22, 07:07:12 pm

On Sun, May 15, 2022 at 7:32 AM Priyansh Sharma @.***> wrote:

Closed #2 https://github.com/Spidy-PS/Steganography-Tools/issues/2.

— Reply to this email directly, view it on GitHub https://github.com/Spidy-PS/Steganography-Tools/issues/2#event-6610776138, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYTHJ4JI7WZXTTTPVZBHHJLVKBLMBANCNFSM5VOBV5NA . You are receiving this because you authored the thread.Message ID: @.***>

Priyansh-15 commented 2 years ago

Hii @shivampatel0902 , The image in which you want to embed the text message make sure it is of the format "ABC.jpg" and update the name of the image in the code part . 2 then when you run the function to encode some message make sure the stego image(new image after encoding) name should be of format "XYZ.png" and then run it it will show successfully encoded message . 1 then try to run decode function . Hope it will resolve your issue .

shivampatel0902 commented 2 years ago

[image: image.png] see this as per as you can say i can do that but not show results

[image: Mailtrack] https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality11& Sender notified by Mailtrack https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality11& 12/06/22, 07:56:46 pm

On Sun, Jun 12, 2022 at 7:31 PM Priyansh Sharma @.***> wrote:

Hii @shivampatel0902 https://github.com/shivampatel0902 , The image in which you want to embed the text message make sure it is of the format "ABC.jpg" and update the name of the image in the code part . [image: 2] https://user-images.githubusercontent.com/77832407/173236891-3eacf5e3-d421-4de2-81b6-2b3f89a64537.jpg then when you run the function to encode some message make sure the stego image(new image after encoding) name should be of format "XYZ.png" and then run it it will show successfully encoded message . [image: 1] https://user-images.githubusercontent.com/77832407/173236860-4303e620-e7e8-4a9e-a337-7d935c2123cf.jpg then try to run decode function . Hope it will resolve your issue .

— Reply to this email directly, view it on GitHub https://github.com/Spidy-PS/Steganography-Tools/issues/2#issuecomment-1153179076, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYTHJ4IK5U57SEF3ZYOZURTVOXUSBANCNFSM5VOBV5NA . You are receiving this because you were mentioned.Message ID: @.***>

Priyansh-15 commented 2 years ago

@shivampatel0902 your image that you uploaded is not visible please send it properly and try to paste your code too . make sure you preview that code is visible on this message and any image you upload .

shivampatel0902 commented 2 years ago

[image: Capture.PNG]

import cv2 import numpy as np

def txt_encode(text): l = len(text) i = 0 add = '' while i <1: t = ord(text[i]) if (t >= 32 and t <= 64): t1 = t + 48 t2 = t1 ^ 170 # 170: 10101010 res = bin(t2)[2:].zfill(8) add += "0011" + res

    else:

        t1 = t - 48
        t2 = t1 ^ 170
        res = bin(t2)[2:].zfill(8)
        add += "0110" + res
    i += 1
res1 = add + "111111111111"
print("The string after binary conversion appyling all the

transformation :- " + (res1)) length = len(res1) print("Length of binary after conversion:- ", length) HM_SK = "" ZWC = {"00": u'\u200C', "01": u'\u202C', "11": u'\u202D', "10": u'\u200E'} file1 = open("covertext.txt", "r+") nameoffile = input("\nEnter the name of the Stego file after Encoding(with extension):- ") file3 = open(nameoffile, "w+", encoding="utf-8") word = [] for line in file1: word += line.split() i = 0 while (i < len(res1)): s = word[int(i / 12)] j = 0 x = "" HM_SK = "" while (j < 12): x = res1[j + i] + res1[i + j + 1] HM_SK += ZWC[x] j += 2 s1 = s + HM_SK file3.write(s1) file3.write(" ") i += 12 t = int(len(res1) / 12) while t < len(word): file3.write(word[t]) file3.write(" ") t += 1 file3.close() file1.close() print("\nStego file has successfully generated")

def encode_txt_data(): count2 = 0 file1 = open("covertext.txt", "r") for line in file1: for word in line.split(): count2 = count2 + 1 file1.close() bt = int(count2) print("Maximum number of words that can be inserted :- ", int(bt / 6)) text1 = input("\nEnter data to be encoded:- ") l = len(text1) if (l <= bt): print("\nInputed message can be hidden in the cover file\n") txt_encode(text1) else: print("\nString is too big please reduce string size") encode_txt_data()

def BinaryToDecimal(binary): string = int(binary, 2) return string

def decode_txt_data(): ZWC_reverse = {u'\u200C': "00", u'\u202C': "01", u'\u202D': "11", u'\u200E': "10"} stego = input("\nPlease enter the stego file name(with extension) to decode the message:- ") file4 = open(stego, "r", encoding="utf-8") temp = '' for line in file4: for words in line.split(): T1 = words binary_extract = "" for letter in T1: if (letter in ZWC_reverse): binary_extract += ZWC_reverse[letter] if binary_extract == "111111111111": break else: temp += binary_extract print("\nEncrypted message presented in code bits:", temp) lengthd = len(temp) print("\nLength of encoded bits:- ", lengthd) i = 0 a = 0 b = 4 c = 4 d = 12 final = '' while i < len(temp): t3 = temp[a:b] a += 12 b += 12 i += 12 t4 = temp[c:d] c += 12 d += 12 if (t3 == '0110'): decimal_data = BinaryToDecimal(t4) final += chr((decimal_data ^ 170) + 48) elif (t3 == '0011'): decimal_data = BinaryToDecimal(t4) final += chr((decimal_data ^ 170) - 48) print("\nMessage after decoding from the stego file:- ", final)

def txt_steg(): while True: print("\n\t\tTEXT STEGANOGRAPHY OPERATIONS") print("1. Encode the Text message") print("2. Decode the Text message") print("3. Exit") choice1 = int(input("Enter the Choice:")) if choice1 == 1: encode_txt_data() elif choice1 == 2: decrypted = decode_txt_data() elif choice1 == 3: break else: print("Incorrect Choice") print("\n")

def msgtobinary(msg): if type(msg) == str: result = ''.join([format(ord(i), "08b") for i in msg])

elif type(msg) == bytes or type(msg) == np.ndarray:
    result = [format(i, "08b") for i in msg]

elif type(msg) == int or type(msg) == np.uint8:
    result = format(msg, "08b")

else:
    raise TypeError("Input type is not supported in this function")

return result

def encode_img_data(img): data = input("\nEnter the data to be Encoded in Image :") if (len(data) == 0): raise ValueError('Data entered to be encoded is empty')

nameoffile = input("\nEnter the name of the New Image (Stego

Image) after Encoding(with extension):")

no_of_bytes = (img.shape[0] * img.shape[1] * 3) // 8

print("\t\nMaximum bytes to encode in Image :", no_of_bytes)

if (len(data) > no_of_bytes):
    raise ValueError("Insufficient bytes Error, Need Bigger Image

or give Less Data !!")

data += '*^*^*'

binary_data = msgtobinary(data)
print("\n")
print(binary_data)
length_data = len(binary_data)

print("\nThe Length of Binary data", length_data)

index_data = 0

for i in img:
    for pixel in i:
        r, g, b = msgtobinary(pixel)
        if index_data < length_data:
            pixel[0] = int(r[:-1] + binary_data[index_data], 2)
            index_data += 1
        if index_data < length_data:
            pixel[1] = int(g[:-1] + binary_data[index_data], 2)
            index_data += 1
        if index_data < length_data:
            pixel[2] = int(b[:-1] + binary_data[index_data], 2)
            index_data += 1
        if index_data >= length_data:
            break
cv2.imwrite(nameoffile, img)
print("\nEncoded the data successfully in the Image and the image

is successfully saved with name ", nameoffile)

def decode_img_data(img): data_binary = "" for i in img: for pixel in i: r, g, b = msgtobinary(pixel) data_binary += r[-1] data_binary += g[-1] data_binary += b[-1] total_bytes = [data_binary[i: i + 8] for i in range(0, len(data_binary), 8)] decoded_data = "" for byte in total_bytes: decoded_data += chr(int(byte, 2)) if decoded_data[-1:] == "^^*": print("\n\nThe Encoded data which was hidden in the Image was :-- ", decoded_data[:-5]) return

def img_steg(): while True: print("\n\t\tIMAGE STEGANOGRAPHY OPERATIONS\n") print("1. Encode the Text message") print("2. Decode the Text message") print("3. Exit") choice1 = int(input("Enter the Choice: ")) if choice1 == 1: image = cv2.imread("Cover.jpg") encode_img_data(image) elif choice1 == 2: image1 = cv2.imread(input("Enter the Image you need to Decode to get the Secret message : ")) decode_img_data(image1) elif choice1 == 3: break else: print("Incorrect Choice") print("\n")

def encode_aud_data(): import wave

nameoffile = input("Enter name of the file (with extension) :- ")
song = wave.open(nameoffile, mode='rb')

nframes = song.getnframes()
frames = song.readframes(nframes)
frame_list = list(frames)
frame_bytes = bytearray(frame_list)

data = input("\nEnter the secret message :- ")

res = ''.join(format(i, '08b') for i in bytearray(data, encoding='utf-8'))
print("\nThe string after binary conversion :- " + (res))
length = len(res)
print("\nLength of binary after conversion :- ", length)

data = data + '*^*^*'

result = []
for c in data:
    bits = bin(ord(c))[2:].zfill(8)
    result.extend([int(b) for b in bits])

j = 0
for i in range(0, len(result), 1):
    res = bin(frame_bytes[j])[2:].zfill(8)
    if res[len(res) - 4] == result[i]:
        frame_bytes[j] = (frame_bytes[j] & 253)  # 253: 11111101
    else:
        frame_bytes[j] = (frame_bytes[j] & 253) | 2
        frame_bytes[j] = (frame_bytes[j] & 254) | result[i]
    j = j + 1

frame_modified = bytes(frame_bytes)

stegofile = input("\nEnter name of the stego file (with extension) :- ")
with wave.open(stegofile, 'wb') as fd:
    fd.setparams(song.getparams())
    fd.writeframes(frame_modified)
print("\nEncoded the data successfully in the audio file.")
song.close()

def decode_aud_data(): import wave

nameoffile = input("Enter name of the file to be decoded :- ")
song = wave.open(nameoffile, mode='rb')

nframes = song.getnframes()
frames = song.readframes(nframes)
frame_list = list(frames)
frame_bytes = bytearray(frame_list)

extracted = ""
p = 0
for i in range(len(frame_bytes)):
    if (p == 1):
        break
    res = bin(frame_bytes[i])[2:].zfill(8)
    if res[len(res) - 2] == 0:
        extracted += res[len(res) - 4]
    else:
        extracted += res[len(res) - 1]

    all_bytes = [extracted[i: i + 8] for i in range(0, len(extracted), 8)]
    decoded_data = ""
    for byte in all_bytes:
        decoded_data += chr(int(byte, 2))
        if decoded_data[-5:] == "*^*^*":
            print("The Encoded data was :--", decoded_data[:-5])
            p = 1
            break

def aud_steg(): while True: print("\n\t\tAUDIO STEGANOGRAPHY OPERATIONS") print("1. Encode the Text message") print("2. Decode the Text message") print("3. Exit") choice1 = int(input("Enter the Choice:")) if choice1 == 1: encode_aud_data() elif choice1 == 2: decode_aud_data() elif choice1 == 3: break else: print("Incorrect Choice") print("\n")

def KSA(key): key_length = len(key) S = list(range(256)) j = 0 for i in range(256): j = (j + S[i] + key[i % key_length]) % 256 S[i], S[j] = S[j], S[i] return S

def PRGA(S, n): i = 0 j = 0 key = [] while n > 0: n = n - 1 i = (i + 1) % 256 j = (j + S[i]) % 256 S[i], S[j] = S[j], S[i] K = S[(S[i] + S[j]) % 256] key.append(K) return key

def preparing_key_array(s): return [ord(c) for c in s]

def encryption(plaintext): print("Enter the key : ") key = input() key = preparing_key_array(key)

S = KSA(key)

keystream = np.array(PRGA(S, len(plaintext)))
plaintext = np.array([ord(i) for i in plaintext])

cipher = keystream ^ plaintext
ctext = ''
for c in cipher:
    ctext = ctext + chr(c)
return ctext

def decryption(ciphertext): print("Enter the key : ") key = input() key = preparing_key_array(key)

S = KSA(key)

keystream = np.array(PRGA(S, len(ciphertext)))
ciphertext = np.array([ord(i) for i in ciphertext])

decoded = keystream ^ ciphertext
dtext = ''
for c in decoded:
    dtext = dtext + chr(c)
return dtext

def embed(frame): data = input("\nEnter the data to be Encoded in Video :") data = encryption(data) print("The encrypted data is : ", data) if (len(data) == 0): raise ValueError('Data entered to be encoded is empty')

data += '*^*^*'

binary_data = msgtobinary(data)
length_data = len(binary_data)

index_data = 0

for i in frame:
    for pixel in i:
        r, g, b = msgtobinary(pixel)
        if index_data < length_data:
            pixel[0] = int(r[:-1] + binary_data[index_data], 2)
            index_data += 1
        if index_data < length_data:
            pixel[1] = int(g[:-1] + binary_data[index_data], 2)
            index_data += 1
        if index_data < length_data:
            pixel[2] = int(b[:-1] + binary_data[index_data], 2)
            index_data += 1
        if index_data >= length_data:
            break
    return frame

def extract(frame): data_binary = "" final_decoded_msg = "" for i in frame: for pixel in i: r, g, b = msgtobinary(pixel) data_binary += r[-1] data_binary += g[-1] data_binary += b[-1] total_bytes = [data_binary[i: i + 8] for i in range(0, len(data_binary), 8)] decoded_data = "" for byte in total_bytes: decoded_data += chr(int(byte, 2)) if decoded_data[-5:] == "^^*": for i in range(0, len(decoded_data) - 5): final_decoded_msg += decoded_data[i] final_decoded_msg = decryption(final_decoded_msg) print("\n\nThe Encoded data which was hidden in the Video was :--\n", final_decoded_msg) return

def encode_vid_data(): cap = cv2.VideoCapture("video.mp4") vidcap = cv2.VideoCapture("video.mp4") fourcc = cv2.VideoWriter_fourcc(*'XVID') frame_width = int(vidcap.get(3)) frame_height = int(vidcap.get(4))

size = (frame_width, frame_height)
out = cv2.VideoWriter('stego.mp4', fourcc, 25.0, size)
max_frame = 0;
while (cap.isOpened()):
    ret, frame = cap.read()
    if ret == False:
        break
    max_frame += 1
cap.release()
print("Total number of Frame in selected Video :", max_frame)
print("Enter the frame number where you want to embed data : ")
n = int(input())
frame_number = 0
while (vidcap.isOpened()):
    frame_number += 1
    ret, frame = vidcap.read()
    if ret == False:
        break
    if frame_number == n:
        change_frame_with = embed(frame)
        frame_ = change_frame_with
        frame = change_frame_with
    out.write(frame)

print("\nEncoded the data successfully in the video file.")
return frame_

def decode_viddata(frame): cap = cv2.VideoCapture('stego.mp4') max_frame = 0; while (cap.isOpened()): ret, frame = cap.read() if ret == False: break max_frame += 1 print("Total number of Frame in selected Video :", max_frame) print("Enter the secret frame number from where you want to extract data") n = int(input()) vidcap = cv2.VideoCapture('stego.mp4') frame_number = 0 while (vidcap.isOpened()): frame_number += 1 ret, frame = vidcap.read() if ret == False: break if framenumber == n: extract(frame) return

def vid_steg(): while True: print("\n\t\tVIDEO STEGANOGRAPHY OPERATIONS") print("1. Encode the Text message") print("2. Decode the Text message") print("3. Exit") choice1 = int(input("Enter the Choice:")) if choice1 == 1: a = encode_vid_data() elif choice1 == 2: decode_vid_data(a) elif choice1 == 3: break else: print("Incorrect Choice") print("\n")

def main(): print("\t\t STEGANOGRAPHY") while True: print("\n\t\t\tMAIN MENU\n") print("1. IMAGE STEGANOGRAPHY {Hiding Text in Image cover file}") print("2. TEXT STEGANOGRAPHY {Hiding Text in Text cover file}") print("3. AUDIO STEGANOGRAPHY {Hiding Text in Audio cover file}") print("4. VIDEO STEGANOGRAPHY {Hiding Text in Video cover file}") print("5. Exit\n") choice1 = int(input("Enter the Choice: ")) if choice1 == 1: img_steg() elif choice1 == 2: txt_steg() elif choice1 == 3: aud_steg() elif choice1 == 4: vid_steg() elif choice1 == 5: break else: print("Incorrect Choice") print("\n\n")

if name == "main": main()

[image: Mailtrack] https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality11& Sender notified by Mailtrack https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality11& 12/06/22, 08:24:12 pm

On Sun, Jun 12, 2022 at 8:04 PM Priyansh Sharma @.***> wrote:

Reopened #2 https://github.com/Spidy-PS/Steganography-Tools/issues/2.

— Reply to this email directly, view it on GitHub https://github.com/Spidy-PS/Steganography-Tools/issues/2#event-6791532035, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYTHJ4OTHLT2IB2YSL4OHBLVOXYPDANCNFSM5VOBV5NA . You are receiving this because you were mentioned.Message ID: @.***>

Priyansh-15 commented 2 years ago

@shivampatel0902 Please try this :

import numpy as np
import pandas as pand
import os
import cv2
def msgtobinary(msg):
    if type(msg) == str:
        result= ''.join([ format(ord(i), "08b") for i in msg ])

    elif type(msg) == bytes or type(msg) == np.ndarray:
        result= [ format(i, "08b") for i in msg ]

    elif type(msg) == int or type(msg) == np.uint8:
        result=format(msg, "08b")

    else:
        raise TypeError("Input type is not supported in this function")

    return result
def encode_img_data(img):
    data=input("\nEnter the data to be Encoded in Image :")    
    if (len(data) == 0): 
        raise ValueError('Data entered to be encoded is empty')

    nameoffile = input("\nEnter the name of the New Image (Stego Image) after Encoding(with extension):")

    no_of_bytes=(img.shape[0] * img.shape[1] * 3) // 8

    print("\t\nMaximum bytes to encode in Image :", no_of_bytes)

    if(len(data)>no_of_bytes):
        raise ValueError("Insufficient bytes Error, Need Bigger Image or give Less Data !!")

    data +='*^*^*'    

    binary_data=msgtobinary(data)
    print("\n")
    print(binary_data)
    length_data=len(binary_data)

    print("\nThe Length of Binary data",length_data)

    index_data = 0

    for i in img:
        for pixel in i:
            r, g, b = msgtobinary(pixel)
            if index_data < length_data:
                pixel[0] = int(r[:-1] + binary_data[index_data], 2) 
                index_data += 1
            if index_data < length_data:
                pixel[1] = int(g[:-1] + binary_data[index_data], 2) 
                index_data += 1
            if index_data < length_data:
                pixel[2] = int(b[:-1] + binary_data[index_data], 2) 
                index_data += 1
            if index_data >= length_data:
                break
    cv2.imwrite(nameoffile,img)
    print("\nEncoded the data successfully in the Image and the image is successfully saved with name ",nameoffile)
def decode_img_data(img):
    data_binary = ""
    for i in img:
        for pixel in i:
            r, g, b = msgtobinary(pixel) 
            data_binary += r[-1]  
            data_binary += g[-1]  
            data_binary += b[-1]  
            total_bytes = [ data_binary[i: i+8] for i in range(0, len(data_binary), 8) ]
            decoded_data = ""
            for byte in total_bytes:
                decoded_data += chr(int(byte, 2))
                if decoded_data[-5:] == "*^*^*": 
                    print("\n\nThe Encoded data which was hidden in the Image was :--  ",decoded_data[:-5])
                    return 
def img_steg():
    while True:
        print("\n\t\tIMAGE STEGANOGRAPHY OPERATIONS\n") 
        print("1. Encode the Text message") 
        print("2. Decode the Text message") 
        print("3. Exit")  
        choice1 = int(input("Enter the Choice: "))   
        if choice1 == 1:
            image=cv2.imread("Cover.jpg")
            encode_img_data(image)
        elif choice1 == 2:
            image1=cv2.imread(input("Enter the Image you need to Decode to get the Secret message :  "))
            decode_img_data(image1)
        elif choice1 == 3:
            break
        else:
            print("Incorrect Choice")
        print("\n")
def main():
    print("\t\t      STEGANOGRAPHY")   
    while True:  
        print("\n\t\t\tMAIN MENU\n")  
        print("1. IMAGE STEGANOGRAPHY {Hiding Text in Image cover file}")  
        print("2. Exit\n")  
        choice1 = int(input("Enter the Choice: "))   
        if choice1 == 1: 
            img_steg()
        elif choice1 == 2:
            break
        else:
            print("Incorrect Choice")
        print("\n\n")
if __name__ == "__main__":
    main()

And @shivampatel0902 make sure the initial image that you want to do encoding in must be named "Cover.jpg" and the new name of stego image {encoded image } must be of format "XYZ.png" . Hope this will resolve your issue .

shivampatel0902 commented 2 years ago

now completely run a project thank you so much ..

[image: Mailtrack] https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality11& Sender notified by Mailtrack https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality11& 14/06/22, 10:47:55 am

On Mon, Jun 13, 2022 at 4:16 PM Priyansh Sharma @.***> wrote:

@shivampatel0902 https://github.com/shivampatel0902 Please try this :

import numpy as np import pandas as pand import os import cv2

def msgtobinary(msg): if type(msg) == str: result= ''.join([ format(ord(i), "08b") for i in msg ])

elif type(msg) == bytes or type(msg) == np.ndarray:
    result= [ format(i, "08b") for i in msg ]

elif type(msg) == int or type(msg) == np.uint8:
    result=format(msg, "08b")

else:
    raise TypeError("Input type is not supported in this function")

return result

def encode_img_data(img): data=input("\nEnter the data to be Encoded in Image :") if (len(data) == 0): raise ValueError('Data entered to be encoded is empty')

nameoffile = input("\nEnter the name of the New Image (Stego Image) after Encoding(with extension):")

no_of_bytes=(img.shape[0] * img.shape[1] * 3) // 8

print("\t\nMaximum bytes to encode in Image :", no_of_bytes)

if(len(data)>no_of_bytes):
    raise ValueError("Insufficient bytes Error, Need Bigger Image or give Less Data !!")

data +='*^*^*'

binary_data=msgtobinary(data)
print("\n")
print(binary_data)
length_data=len(binary_data)

print("\nThe Length of Binary data",length_data)

index_data = 0

for i in img:
    for pixel in i:
        r, g, b = msgtobinary(pixel)
        if index_data < length_data:
            pixel[0] = int(r[:-1] + binary_data[index_data], 2)
            index_data += 1
        if index_data < length_data:
            pixel[1] = int(g[:-1] + binary_data[index_data], 2)
            index_data += 1
        if index_data < length_data:
            pixel[2] = int(b[:-1] + binary_data[index_data], 2)
            index_data += 1
        if index_data >= length_data:
            break
cv2.imwrite(nameoffile,img)
print("\nEncoded the data successfully in the Image and the image is successfully saved with name ",nameoffile)

def decode_img_data(img): data_binary = "" for i in img: for pixel in i: r, g, b = msgtobinary(pixel) data_binary += r[-1] data_binary += g[-1] data_binary += b[-1] total_bytes = [ data_binary[i: i+8] for i in range(0, len(data_binary), 8) ] decoded_data = "" for byte in total_bytes: decoded_data += chr(int(byte, 2)) if decoded_data[-5:] == "^^*": print("\n\nThe Encoded data which was hidden in the Image was :-- ",decoded_data[:-5]) return

def img_steg(): while True: print("\n\t\tIMAGE STEGANOGRAPHY OPERATIONS\n") print("1. Encode the Text message") print("2. Decode the Text message") print("3. Exit") choice1 = int(input("Enter the Choice: ")) if choice1 == 1: image=cv2.imread("Cover.jpg") encode_img_data(image) elif choice1 == 2: image1=cv2.imread(input("Enter the Image you need to Decode to get the Secret message : ")) decode_img_data(image1) elif choice1 == 3: break else: print("Incorrect Choice") print("\n")

def main(): print("\t\t STEGANOGRAPHY") while True: print("\n\t\t\tMAIN MENU\n") print("1. IMAGE STEGANOGRAPHY {Hiding Text in Image cover file}") print("2. Exit\n") choice1 = int(input("Enter the Choice: ")) if choice1 == 1: img_steg() elif choice1 == 2: break else: print("Incorrect Choice") print("\n\n")

if name == "main": main()

And @shivampatel0902 https://github.com/shivampatel0902 make sure the initial image that you want to do encoding in must be named "Cover.jpg" and the new name of stego image {encoded image } must be of format "XYZ.png" . Hope this will resolve your issue .

— Reply to this email directly, view it on GitHub https://github.com/Spidy-PS/Steganography-Tools/issues/2#issuecomment-1153762476, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYTHJ4P5MIJF7S76NAP5BN3VO4GOXANCNFSM5VOBV5NA . You are receiving this because you were mentioned.Message ID: @.***>

Nihal-Tiwari commented 2 years ago

Hey @Priyansh-15 could you share you linkedIn/Twitter/Insta/discord I wanna talk to you Thanks

Priyansh-15 commented 2 years ago

Hey @Priyansh-15 could you share you linkedIn/Twitter/Insta/discord I wanna talk to you Thanks

LinkedIn : https://www.linkedin.com/in/priyansh-sharma-bb4095216/