def decode_nth_bit(inp, stegobit): """Retrieves a text message in a specific colour value bit of an image""" assert os.path.isfile(inp), '%s is not a file.' % inp assert 0 <= stegobit <= 7, '%d is an invalid bit value.' % stegobit img = read_img(inp) res = decode_msg_from_bit(img, stegobit) print res return res
def decode_nth_bit(inp, stegobit): """Retrieves a text message in a specific colour value bit of an image""" assert os.path.isfile(inp), '%s is not a file.' % inp assert 0 <= stegobit <= 7, '%d is an invalid bit value.' %stegobit img = read_img(inp) res = decode_msg_from_bit(img, stegobit) print res return res
def encode_nth_bit(inp, out, msg, stegobit): """Hides a text message in one bit of each colour value of an image.""" assert os.path.isfile(inp), '%s is not a file.' % inp assert 0 <= stegobit <= 7, '%d is an invalid bit value.' % stegobit img = read_img(inp) #while writing an jpg image, compression destroys the steganographic message ext = os.path.splitext(out)[1].lower() assert ext != '.jpeg' and ext != '.jpg', 'jpg/jpeg is currently not a valid extension for output images.' write_img(out, encode_msg_in_bit(img, msg, stegobit))
def decode_patchwork(inp, key_array_A, key_array_B): """Retrieves a text message which is hidden by patchwork steganography""" assert os.path.isfile(inp), '%s is not a file.' % inp img = read_img(inp) key_array_A = json.loads(key_array_A) key_array_B = json.loads(key_array_B) res = decode_msg_with_patchwork(img, key_array_A, key_array_B) print res return res
def encode_nth_bit(inp, out, msg, stegobit): """Hides a text message in one bit of each colour value of an image.""" assert os.path.isfile(inp), '%s is not a file.' % inp assert 0 <= stegobit <= 7, '%d is an invalid bit value.' %stegobit img = read_img(inp) #while writing an jpg image, compression destroys the steganographic message ext = os.path.splitext(out)[1].lower() assert ext != '.jpeg' and ext != '.jpg', 'jpg/jpeg is currently not a valid extension for output images.' write_img(out, encode_msg_in_bit(img, msg, stegobit))
def encode_patchwork(inp, out, msg): """Hides a text message in pixels of two key streams.""" assert os.path.isfile(inp), '%s is not a file.' % inp img = read_img(inp) A = get_random_pos(len(msg), img) B = get_random_pos(len(msg), img, A) print "A: %s" % json.dumps(A) print "B: %s" % json.dumps(B) #while writing an jpg image, compression destroys the steganographic message ext = os.path.splitext(out)[1].lower() assert ext != '.jpeg' and ext != '.jpg', 'jpg/jpeg is currently not a valid extension for output images.' save_image(out, encode_msg_with_patchwork(img, msg, A, B))
def encode_patchwork(inp, out, msg): """Hides a text message in pixels of two key streams.""" assert os.path.isfile(inp), '%s is not a file.' % inp img = read_img(inp) A = get_random_pos(len(msg), img) B = get_random_pos(len(msg), img, A) print "A: %s" %json.dumps(A) print "B: %s" %json.dumps(B) #while writing an jpg image, compression destroys the steganographic message ext = os.path.splitext(out)[1].lower() assert ext != '.jpeg' and ext != '.jpg', 'jpg/jpeg is currently not a valid extension for output images.' save_image(out, encode_msg_with_patchwork(img, msg, A, B))
def decode_patchwork(inp): """Retrieves a text message which is hidden by patchwork steganography""" assert os.path.isfile(inp), '%s is not a file.' % inp img = read_img(inp) #Truyen gia tri toa do x,y cua 2 mang A,B key_array_A = [[61, 293], [37, 159], [127, 110], [66, 235], [17, 229], [226, 58], [185, 328]] key_array_B = [[210, 230], [21, 517], [126, 263], [126, 564], [111, 503], [110, 255], [38, 179]] #key_array_A = json.loads(key_array_A) #key_array_B = json.loads(key_array_B) res = decode_msg_with_patchwork(img, key_array_A, key_array_B) print res return res
from scipy.misc import imsave as save_image import numpy as np import random def diff_methode(img_array, msg): msg_len = len(msg) x = random.randint(0, img_array.shape[0]) y = random.randint(0, img_array.shape[1]) key_array_A = [] key_array_B = [] while len(key_array_A) < msg_len: rand_pix = img_array[(random.randint(0, img_array.shape[0] - 1), random.randint(0, img_array.shape[1] - 1))] for p in img_array: if rand_pix.all(p) and p not in key_array_A and rand_pix not in key_array_A and rand_pix not in key_array_B: key_array_A.append[rand_pix] key_array_B.append[p] print key_array_A print key_array_B ### TESTING ### path = "C:\\Users\\Public\\Pictures\\Sample Pictures\\Koala.jpg" path2 = "C:\\Users\\Public\\Pictures\\Sample Pictures\\KoalaTESTX.jpg" img = read_img(path) print img msg = "This is a new diff methode for stego" diff_methode(img, msg)
def diff_methode(img_array, msg): msg_len = len(msg) x = random.randint(0, img_array.shape[0]) y = random.randint(0, img_array.shape[1]) key_array_A = [] key_array_B = [] while len(key_array_A) < msg_len: rand_pix = img_array[(random.randint(0, img_array.shape[0] - 1), random.randint(0, img_array.shape[1] - 1))] for p in img_array: if rand_pix.all( p ) and p not in key_array_A and rand_pix not in key_array_A and rand_pix not in key_array_B: key_array_A.append[rand_pix] key_array_B.append[p] print key_array_A print key_array_B ### TESTING ### path = "C:\\Users\\Public\\Pictures\\Sample Pictures\\Koala.jpg" path2 = "C:\\Users\\Public\\Pictures\\Sample Pictures\\KoalaTESTX.jpg" img = read_img(path) print img msg = "This is a new diff methode for stego" diff_methode(img, msg)