0% found this document useful (0 votes)
24 views2 pages

Steganography Nis Project

This document discusses hiding text within an image file. It takes in text and a security key from the user, then encrypts each character by XORing it with the corresponding character in the key. It stores the encrypted text by overwriting pixel values in the image. To extract the text, it decrypts the pixel values using the same key.

Uploaded by

Dev Pathak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Steganography Nis Project

This document discusses hiding text within an image file. It takes in text and a security key from the user, then encrypts each character by XORing it with the corresponding character in the key. It stores the encrypted text by overwriting pixel values in the image. To extract the text, it decrypts the pixel values using the same key.

Uploaded by

Dev Pathak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import cv2

import string
import os
d={}
c={}

for i in range(255):
d[chr(i)]=i
c[i]=chr(i)

#print(c)

x=cv2.imread("image.jpg")

i=x.shape[0]
j=x.shape[1]
print(i,j)

key=input("Enter key to edit(Security Key) : ")


text=input("Enter text to hide : ")

kl=0
tln=len(text)
z=0 #decides plane
n=0 #number of row
m=0 #number of column

l=len(text)

for i in range(l):
x[n,m,z]=d[text[i]]^d[key[kl]]
n=n+1
m=m+1
m=(m+1)%3 #this is for every value of z , remainder will be between 0,1,2 . i.e
G,R,B plane will be set automatically.
#whatever be the value of z , z=(z+1)%3 will always between 0,1,2 .
The same concept is used for random number in dice and card games.
kl=(kl+1)%len(key)

cv2.imwrite("encrypted_img.jpg",x)
os.startfile("encrypted_img.jpg")
print("Data Hiding in Image completed successfully.")
#x=cv2.imread(“encrypted_img.jpg")

kl=0
tln=len(text)
z=0 #decides plane
n=0 #number of row
m=0 #number of column

ch = int(input("\nEnter 1 to extract data from Image : "))

if ch == 1:
key1=input("\n\nRe enter key to extract text : ")
decrypt=""

if key == key1 :
for i in range(l):
decrypt+=c[x[n,m,z]^d[key[kl]]]
n=n+1
m=m+1
m=(m+1)%3
kl=(kl+1)%len(key)
print("Encrypted text was : ",decrypt)
else:
print("Key doesn't matched.")
else:
print("Thank you. EXITING.")

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy