jueves, 1 de noviembre de 2012

Code steganography

This code is only to encrypt the image

Here the code:
import Image
imagen = Image.open("006.jpg")
arch = open("mensaje.txt","r")
message = []
todec = []
count = 0
psize = 0
x, y = imagen.size
pixels = imagen.load()
counter = 0
sizet = 0
ident = 0
indicador = 0
pix = 0
ctrls = 0
cant = 0
o = 0
v = 0
a = 0
rgb = 0
d = 0
for i in arch.xreadlines():
data = i
message.append(data)
count = count + len(data)
d = d + len(data)
psize = len(message)
for i in range(psize):
size = len(message[i])
for j in range(size):
todec.append(ord(message[i][j]))
multi = x * y
size = int(len(todec))
separate = multi/size
constant = separate/4
for i in range(x):
for j in range(y):
(o,v,a) = pixels[i,j]
if cant == 0:
mod = o % 7
if mod == 1:
r = size
pixels[i,j] = (r,v,a)
cant = cant + 1
else:
if pix < separate:
if count > 0:
indicador = todec[sizet]
if rgb == 0:
r = todec[sizet]
pixels[i,j] = (r,v,a)
sizet = sizet + 1
count = count - 1
pix = separate
if rgb == 1:
g = todec[sizet]
pixels[i,j] = (o,g,a)
size = size + 1
count = count - 1
pix = separate
if rgb == 2:
B = todec[sizet]
pixels[i,j] = (a,v,B)
size = size + 1
count = count - 1
pix = separate
if ctrls >= separate:
separate = separate + constant/2
pix = 0
ctrls = ctrls + 1
if rgb == 0:
rgb = 1
else:
if rgb == 1:
rgb = 2
else:
if rgb ==2:
rgb = 0
print "Copia exitosa"
imagen.save("004.png")

No hay comentarios:

Publicar un comentario