Beispiel #1
0
def embed(cover, secret, occ, saveLocation="output.avi"):
    '''Embeds  images. Call this function when the module is imported
	cover = Cover Video Path/Location
	secret = secret Media Path/Location
	occ = List of occupied frames'''

    global key
    # Opening video & extracting frames
    cap = cv2.VideoCapture(cover)
    frameCount = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
    fps = cap.get(cv2.CAP_PROP_FPS)
    frames = ifvm.getAllFrames(cap)
    not_occupied = [i for i in range(frameCount) if i not in occ]

    # Opening secret Image and converting to string for embedding
    secret_media_text_file_path = "secret_file_154861.txt"
    with open(secret, "rb") as mediaFile:
        media_data = base64.b64encode(mediaFile.read())

    with open(secret_media_text_file_path, "w") as txt:
        txt.write(media_data)

    # define capacity of each data frame
    h, w = frames[0].shape[:2]
    pixelCount = h * w - 1
    byteCapacity = pixelCount / 3  # defines maximum no. of bytes that can be stored in an image (Ref. http://domnit.org/blog/2007/02/stepic-explanation.html)

    blocks = ifvm.generateTextBlocks(secret_media_text_file_path, byteCapacity)
    os.remove(secret_media_text_file_path)
    index = ifvm.generateRandomFrameNo(len(frames), occ, not_occupied)
    key = ifvm.generateIndexHash(index)

    # generating data that will be encoded in index frame
    indexData = ifvm.generateIndexData('output.txt', secret.split('.')[-1])

    for block in blocks:
        loc = ifvm.generateRandomFrameNo(len(frames), occ, not_occupied)
        indexData += str(loc) + '.'
        img = Image.fromarray(frames[loc])
        stegimg = stepic.encode(img, block)
        frames[loc] = np.array(stegimg)

    # steganography on index frame
    print 'Index Frame Data: ', indexData
    img = Image.fromarray(frames[index])
    stegimg = stepic.encode(img, indexData)
    frames[index] = np.array(stegimg)
    saveLocation = ifvm.writeToVideo(frames, saveLocation, fps)
    return (saveLocation, occ)
Beispiel #2
0
def encode(file):
    # This Function Will Put data on picture
    img = Image.open(file)
    text = input("Text : ")
    img_stegano = stepic.encode(img, text.encode())
    name = input("Output Name : ")
    img_stegano.save(name)
Beispiel #3
0
 def store(self, data):
     encoded_image = stepic.encode(Image.open("hobbes.png"), compress(data))
     output = StringIO()
     encoded_image.save(output, format="png")
     resp = upload_image(output.getvalue())
     resp_data = json.loads(resp)
     return resp_data["data"]["link"]
Beispiel #4
0
def sliceAndEmbed(frames, secret_img_path, occ):
    ''' Partitions secret image into smaller images and embeds them in cover video '''
    secret_img = Image.open(secret_img_path)
    frame_h, frame_w = frames[0].shape[:2]
    secret_h, secret_w = secret_img.size[1], secret_img.size[0]
    # Temporarily(& Arbritrarily) setting max slice size as 1 sixth of cover image
    max_h, max_w = frame_h / 6, frame_w / 6
    numberOfSlices = ceil(secret_h / max_h) * ceil(secret_w / max_w)
    tiles = image_slicer.slice(secret_img_path, numberOfSlices, save=False)

    # Rough Index data for now
    indexData = str(secret_img.size[0]) + ";" + str(secret_img.size[1]) + ";"
    indexData += str(len(tiles)) + ";" + str(
        tiles[0].image.size[0]) + ';' + str(tiles[0].image.size[1]) + '.'
    index = multi_text_sender.generateRandomFrameNo(len(frames), occ)
    for i in tiles:
        loc = multi_text_sender.generateRandomFrameNo(len(frames), occ)
        indexData += str(loc) + '.'
        cover_img = Image.fromarray(frames[loc])
        i.image = i.image.convert('RGB')
        temp = ioi.hide_image(cover_img, i.image)
        temp = temp.convert('RGBA')
        frames[loc] = np.array(temp)

    # Index
    cover_img = Image.fromarray(frames[index])
    temp = stepic.encode(cover_img, indexData)
    frames[index] = np.array(temp)
    print index
    return frames
Beispiel #5
0
def Main():

	parser = argparse.ArgumentParser()	
	
	parser.add_argument("-i", "--input", help="specify image to have secret message",required=True)
	parser.add_argument("-o", "--output", help="specify output image including secret message",required=True)
	parser.add_argument("-t", "--text", help="specify text to hide",type=str, required=True)
	parser.add_argument('-p','--password', help="enter password to lock",required=True)
	
	args = parser.parse_args()
		
##Password to lock	
	if args.password:
		
		username=getpass.getuser()
		f = open("/home/"+username+"/Documents/hashed.txt", "w")
		data = hashlib.md5(args.password).hexdigest()
		f.write(data)
		f.close()
		
	if args.text:
		
		im=Image.open(args.input)
		im2=stepic.encode(im, args.text)
		im2.save(args.output)
		im2=Image.open(args.output)
Beispiel #6
0
def encode_image(user_image):
    while True:
        try:
            message = input("Enter message to encode: ")
            # Coverts user's message into bytes, so it is usable by stepic.encode.
            bytes_message = message.encode('utf-8')
            # Encodes the user's chosen image with their chosen message.
            encoded_image = stepic.encode(user_image, bytes_message)
            # Allows for user to set new file name.
            file_name = input("Enter a name for the file: ")
            # The encoded file is saved as a PNG with the user's chosen file name.
            encoded_image.save(file_name, 'PNG')
            break

        # General exception catch to ensure that no error is missed.
        # At time of creation, there are no known exceptions for this section, this is just a precaution.
        except Exception as e:
            print(e)
            print("Restarting! \n")
            continue

    # Prints success message.
    print("Image encoded and saved as PNG.")
    # Returns user to the user_choice() function
    user_choice()
Beispiel #7
0
def response(context, flow):
    global db
    if flow.response.headers.get_first("content-type", "").startswith("image") and flow.request.pretty_host(hostheader=True).endswith("i.imgur.com"):
        with decoded(flow.response):  # automatically decode gzipped responses.
            try:
                # Hash returned content for a key in redis
                content_hash = hashlib.md5(flow.response.content).hexdigest()
                # And check redis for said hash
                redis_response = r.get(content_hash)
                if redis_response == None:
                    # Looks like we haven't served this image yet.
                    # Inject us some data
                    # Load image via PIL and cStringIO hackery
                    imghandler = cStringIO.StringIO(flow.response.content)
                    pillowbiter = Image.open(imghandler)
                    # Inject text - you'll change this.
                    s = stepic.encode(pillowbiter, "Image processing in Python is annoying.")
                    # Create a cStringIO handler for stepic output
                    resphandler = cStringIO.StringIO()
                    # Write to it...
                    s.save(resphandler, "png")
                    # "Cache" the steg'd image in Redis
                    r.set(content_hash, resphandler.getvalue())
                # Now we're sure that this image exists in redis, return content
                flow.response.content = r.get(content_hash)
                flow.response.headers["content-type"] = ["image/png"]
            except Exception, e:  # Unknown image types etc.
                pass
def create_encoded_image(input, message, output):
    """
    creates an encoded image (output file)
    """
    i = Image.open(input)
    i2 = stepic.encode(i, message)
    i2.save(output),
Beispiel #9
0
def encrypt_text(image_1, message):
    im = Image.open(image_1)

    im1 = stepic.encode(im, bytes(str(message), encoding='utf-8'))
    im1.save(
        os.path.join(current_app.config['UPLOAD_TEXT_FOLDER'],
                     "encrypted_text_image.png"))
Beispiel #10
0
def create_encoded_image(input, message, output):
    """
    creates an encoded image (output file)
    """
    i = Image.open(input)
    i2 = stepic.encode(i, message)
    i2.save(output),
def Stegano():
    img_stegano = askopenfilename(filetypes=[("Arquivo PNG", "*.png")])
    im = Image.open(img_stegano)
    i = Cripto()
    im2 = stepic.encode(im, i)
    print 'Imagem foi salva'
    salva_foto = asksaveasfile(mode='w', defaultextension=".png")
    im2.save(salva_foto)
Beispiel #12
0
def embedInImage(message, path):
    path = path.encode()
    image = Image.open(path)
    message = message.encode()
    stegoImage = stepic.encode(image, message)
    stegoImageCWD = os.getcwd()
    stegoImagePath = stegoImageCWD + '/secret-file.png'
    stegoImage.save(stegoImagePath, 'PNG')
def Stegano():
	img_stegano = askopenfilename(filetypes=[("Arquivo PNG","*.png")])
	im = Image.open(img_stegano)
	i = Cripto()
	im2 = stepic.encode(im, i)
	print 'Imagem foi salva'
	salva_foto = asksaveasfile(mode='w', defaultextension=".png")
	im2.save(salva_foto)
Beispiel #14
0
def enc():
 iurl=raw_input("enter url of image :")
 im=Image.open(iurl)
 text=raw_input("Enter your text :")
 im2=stepic.encode(im,text)
 curl=raw_input("Enter destination of the crypted image :")
 im2.save(curl,"PNG")
 print('Image has been saved\n\nDo you want to encrypt in another image')
Beispiel #15
0
def encoder():
    x = input("Enter the name of the image you want to open(with extension):")
    y = input("Enter the text you want to input:")
    z = input("Enter the name of output file(without extension):")
    y = y.encode("ascii")
    open1 = Image.open(x)
    modify = stepic.encode(open1, y)
    modify.save(z + ".png")
    print("Success")
Beispiel #16
0
def hide(doc):
    file = open(doc, 'rb')
    data = file.read()
    img = Image.open(r"icons/Lenna.png")
    img2 = stepic.encode(img, data)
    pic = doc[:-5] + '.png'
    img2.save(pic, 'PNG')
    print('done saving data in image...')
    file.close()
    return
Beispiel #17
0
    def hideString(self, srcPath, string, outputPath):
        try:
            im_src = Image.open(srcPath)
        except IOError:
            print 'can not open the %s' % srcPath
            exit(0)

        im_src = stepic.encode(im_src, string)
        im_src.save(outputPath)
        im_src.close()
    def save_data(self):
        if not self.modified:
            return

        im = Image.open(self.prefix + self.src)
        encoded = crypt.encode(self.key, ''.join(self.data))
        enc_im = stepic.encode(im, encoded)
        enc_im.save(self.prefix + self.src)
        self.modified = False
        return
Beispiel #19
0
def encode():
    # The url of the original image
    img_url = request.form['img_url']
    message = request.form['message']
    raw_img = Image.open(StringIO(r.get(img_url).content))
    steg_encoded = stepic.encode(raw_img, message)
    out_buf = StringIO()
    steg_encoded.save(out_buf, 'PNG')
    out_buf.seek(0)
    encoded = out_buf.getvalue().encode("base64")
    return 'data:image/png;base64,' + encoded
def stegoTextBlocks(frames, occ, blocks):
	index = generateRandomFrameNo(len(frames), occ) # <- Index at which our data is hidden (frame no.)
	print 'Index frame no: ', index

	generateIndexHash(index) # generate and print hash code to use as key

	# generating data that will be encoded in index frame
	indexData = generateIndexData('file1.txt','')

	for block in blocks:
		loc = generateRandomFrameNo(len(frames), occ)
		indexData += str(loc) + '.'
		img = Image.fromarray(frames[loc])
		stegimg = stepic.encode(img, block)
		frames[loc] = np.array(stegimg)
		
	# steganography on index frame
	print 'Index Frame Data: ', indexData
	img = Image.fromarray(frames[index])
	stegimg = stepic.encode(img, indexData)
	frames[index] = np.array(stegimg)
	def encryption(self,filetype,info,key):

		location = 'static/'+self.filename
		image = Image.open(location)
		key = int(key)
		cipher_text = self.encrypt(info, key)

		cipher_text = bytes(cipher_text, 'utf-8')

		image = stepic.encode(image,cipher_text)
		image.save(location.split('.')[0]+'1.png','png')
		return True
Beispiel #22
0
def encode(info, img, tx, key):
    try:
        image = Image.open(img)
        contents = encode_file(tx, img)
        contents = contents + "*//*" + info
        encriptador = Encryptor()
        contents = encriptador.run(key, contents)
        st = stepic.encode(image, contents)
        name = img.split(".png")[0] + ".png"
        st.save(name, "png")
    except Exception as e:
        print(e)
Beispiel #23
0
def stegoTextBlocks(frames, occ, blocks):
    index = generateRandomFrameNo(
        len(frames), occ)  # <- Index at which our data is hidden (frame no.)
    print 'Index frame no: ', index

    generateIndexHash(index)  # generate and print hash code to use as key

    # generating data that will be encoded in index frame
    indexData = generateIndexData('file1.txt', '')

    for block in blocks:
        loc = generateRandomFrameNo(len(frames), occ)
        indexData += str(loc) + '.'
        img = Image.fromarray(frames[loc])
        stegimg = stepic.encode(img, block)
        frames[loc] = np.array(stegimg)

    # steganography on index frame
    print 'Index Frame Data: ', indexData
    img = Image.fromarray(frames[index])
    stegimg = stepic.encode(img, indexData)
    frames[index] = np.array(stegimg)
def encode_logic():
    msg = message.get()
    new = newfile.get()
    try:
        im = Image.open(c)
        im1 = stepic.encode(im, bytes(msg, 'utf-8'))
        im1.save(foldername + "/" + new + ".png", 'PNG')
    except:
        Label(screen6, text="").pack()
        Label(screen6, text="Unable to encode").pack()
    else:
        Label(screen6, text="").pack()
        Label(screen6, text="Successfully Encoded", fg="green").pack()
Beispiel #25
0
  def save_data(self):
    """ Saves the block data """

    if not self.modified:
      return

    im = Image.open(self.prefix+self.src)
    encoded = crypt.encode(self.key, ''.join(self.data))

    enc_im = stepic.encode(im, encoded)
    enc_im.save(self.prefix+self.src)

    self.modified = False
    return
Beispiel #26
0
def encode_image(user_name,
                 text_to_encode,
                 APP_ROOT,
                 template_image="./images/source.png"):
    """Encodes a text message into an image
    text_to_encode: the text to encode into the template image
    template_image: the image to use for encoding. An image is provided by default.
    """
    print(user_name + "," + str(text_to_encode) + "," + APP_ROOT + "," +
          template_image)
    name = user_name
    temp_image = Image.open(template_image)
    # red_template = template_image.split()[0]
    # green_template = template_image.split()[1]
    # blue_template = template_image.split()[2]

    # x_size = template_image.size[0]
    # y_size = template_image.size[1]

    #text draw
    # image_text = write_text(text_to_encode, template_image.size)
    # bw_encode = image_text.convert('1')

    #encode text into image
    #encoded_image = Image.new("RGB", (x_size, y_size))
    # pixels = encoded_image.load()
    # for i in range(x_size):
    #     for j in range(y_size):
    #         red_template_pix = bin(red_template.getpixel((i,j)))
    #         old_pix = red_template.getpixel((i,j))
    #         tencode_pix = bin(bw_encode.getpixel((i,j)))

    #         if tencode_pix[-1] == '1':
    #             red_template_pix = red_template_pix[:-1] + '1'
    #         else:
    #             red_template_pix = red_template_pix[:-1] + '0'
    #         pixels[i, j] = (int(red_template_pix, 2), green_template.getpixel((i,j)), blue_template.getpixel((i,j)))

    # encoded_image.save("images/encoded_image.png")

    encoded_image = stepic.encode(temp_image, text_to_encode)

    filename = user_name.split()[0] + "_" + datetime.now().strftime(
        "%d_%m_%y-%H:%M:%S") + ".png"
    UPLOAD_FOLDER = os.path.join(APP_ROOT, "images\\")
    print(filename)
    path = os.path.join(UPLOAD_FOLDER, secure_filename(filename))
    encoded_image.save(path)
    return (path)
Beispiel #27
0
def Steganify(fakeImagePath,realImagePath):#,pathToSaveTo):

    im = Image.open (fakeImagePath)
    im3 = Image.open(realImagePath)
    output = StringIO.StringIO()
    im3.save(output, format = "PNG")
    contents = output.getvalue()
    im2 = stepic.encode(im, contents)
    output.close()
    output = StringIO.StringIO()
    im2.save(output, format = "PNG")
    #im2.save(pathToSaveTo)
    encodedImage = output.getvalue()
    output.close()
    return encodedImage
 def format_image(self):
     print "Formatting ", self.src
     im = Image.open(self.prefix + self.src)
     data_size = im.size[0] * im.size[1] / 3
     if data_size % 16 != 0:
         data_size += data_size % crypt.block_size
         data_size -= 32
     print "Image size: (", im.size[0], ",", im.size[1], ")"
     print "Possible data inside this block:", (data_size / 1024), "Kb"
     data_size -= 32
     data = "$" * data_size
     enc_data = crypt.encode(self.key, data)
     im = stepic.encode(im, enc_data)
     im.save(self.prefix + self.src)
     return data_size
Beispiel #29
0
def encode():
    img = input("Enter image name(with extension): ")
    image = Image.open(img)

    data = input("Enter data to be encoded : ")

    if (len(data) == 0):
        raise ValueError('Data is empty')

    #converting string to bytes format

    data1 = bytes(data, encoding="ascii")

    im1 = stepic.encode(image, data1)

    im1.save(input("Enter the name of new image:- "))
def stegano_encode(encode_text, encode_key, ci):
    # A 256 bit (32 byte) key
    key = encode_key
    #Get The plainText
    plaintext = encode_text
    # key must be bytes, so we convert it
    key = key.encode('utf-8')
    #Encrypt the key & plain Text
    aes = pyaes.AESModeOfOperationCTR(key)
    ciphertext = aes.encrypt(plaintext)
    #Turn the cipher text to binary
    binary_value = binascii.b2a_base64(ciphertext)
    #putting the Binary value inside the image and create the stegano image
    img = Image.open("{}.jpg".format(ci))
    aa = stepic.encode(img, binary_value)
    aa.save("{}_e.png".format(ci))
Beispiel #31
0
 def format_image(self):
   """ Formats an image to be used in the filesystem """
   print "Formatting ", self.src
   im = Image.open(self.prefix+self.src)
   data_size = im.size[0] * im.size[1] / 3
   if data_size % 16 != 0:
     data_size += data_size % crypt.block_size
     data_size -= 32
   print "Image size: (", im.size[0], ",", im.size[1], ")"
   print "Possible data inside this block:", (data_size/1024), "Kb"
   data_size -= 32
   data = "$"*data_size
   enc_data = crypt.encode(self.key, data)
   im = stepic.encode(im, enc_data)
   im.save(self.prefix+self.src)
   return data_size
Beispiel #32
0
def encrypter():

    target = open("pubkey.txt", "r")
    key = target.read()  # read in PEM formatted key from file
    target.close()

    # Create new SHA256 hash
    h = SHA256.new()
    # RSA 2048 bit wrapped with PKCS1 as recommended by documentation
    # Default SHA1 Hash is weak, replacing with SHA2 hash
    rsakey = RSA.importKey(key)
    rsakey = PKCS1_OAEP.new(rsakey, h)

    # Construct a large string to practice encrypting
    As = "A" * 750
    Bs = "B" * 750
    Cs = "C" * 750
    Ds = "D" * 750
    string = As + Bs + Cs + Ds

    # Chunk size = (RSA modulus -2) -( 2 * (hash digest size))
    # In this case (256 -2 ) -( 2 * (32) )= 190
    chunks = splitter(string, 190)

    encrypted = ""

    for chunk in chunks:
        encrypted += rsakey.encrypt(chunk)

    # Lets try compressing the encrypted string a little
    encrypted = zlib.compress(encrypted)

    # Add some b64 encoding to sort of obfuscate our encryption
    encrypted = base64.b64encode(encrypted)
    target = open("testrun.txt", "w")
    output = target.write(encrypted)
    target.close()

    print "Encrypted String is of size:" + str(len(encrypted)) + "\n"

    # Steganography, Hiding the encrypted text in plain sight using least significant bit
    # Image has to be png as it is lossless format.
    im = Image.open("cat.png")
    im2 = stepic.encode(im, encrypted)
    im2.save("encodedcat.png")
Beispiel #33
0
def encode(file, text):
    # Open image or file in which you want to hide your data
    image = Image.open(file)

    # Convert the string to bytes
    text = bytes(text, 'utf-8')

    # Encode some text into your image file and save it in another file
    encodeImage = stepic.encode(image, text)

    # Get the filename from the path
    filename = os.path.splitext(os.path.basename(file))[0]

    # Save the image in PNG file
    encodeImage.save(f'{filename}_enc.png', 'PNG')

    print(f'File Encoded: {filename}_enc.png')
    print(f'String Used To Encode: {text}')
	def naishostepic(self):
	#--------------------------------------------|
        #               Stepic                       |
        #--------------------------------------------|------------------------------------------------------------------------------------------------

		try:
			from PIL import Image
			import stepic
			old_image = raw_input("\033[31mType Path of jpg: \033[0m")
			picture = Image.open(old_image)
			encode_picture = stepic.encode(picture,self.message)
			new_image = raw_input("\033[31mType the name of the new file: \033[0m")
			encode_picture.save(new_image,"PNG")
			picture.show()  

		except:
			print "[-] Stepic Library is not installed!!!"
			raw_input("Press Enter to continue...")
Beispiel #35
0
    def naishostepic(self):
        #--------------------------------------------|
        #               Stepic                       |
        #--------------------------------------------|------------------------------------------------------------------------------------------------

        try:
            from PIL import Image
            import stepic
            old_image = raw_input("\033[31mType Path of jpg: \033[0m")
            picture = Image.open(old_image)
            encode_picture = stepic.encode(picture, self.message)
            new_image = raw_input(
                "\033[31mType the name of the new file: \033[0m")
            encode_picture.save(new_image, "PNG")
            picture.show()

        except:
            print "[-] Stepic Library is not installed!!!"
            raw_input("Press Enter to continue...")
Beispiel #36
0
def encode(img, data_filename):

    image = Image.open(img, 'r')
    with open(data_filename[:-4] + ".enc", 'rb') as fo:
        data = fo.read()

    if (len(data) == 0):
        raise ValueError('Data is empty')

    filename = os.path.basename(img)
    newimg = image.copy()
    newimg = stepic.encode(newimg, base64.b64encode(data))
    new_img_name = filename[:-4] + '_stego_image.png'
    newimg.save(new_img_name, str(filename.split(".")[1].upper()))

    imgs = [filename, new_img_name]
    concatenated = Image.fromarray(
        np.concatenate([np.array(Image.open(x)) for x in imgs], axis=1))
    concatenated.save("difference_" + filename,
                      str(filename.split(".")[1].upper()))
    concatenated.show()
#!/usr/bin/python

#steganography

import stepic, Image

i = Image.open('/tmp/torbuntu.png')

i.show()

steg = stepic.encode(i, 'Hello Bob! How are you doing?')

steg.save('/tmp/steg.jpg', 'JPEG')

i1= Image.open('/tmp/steg.jpg')

i1.show()
from PIL import Image
import stepic

image = Image.open("python.png")
image2 = stepic.encode(image, 'This is the hidden text'.encode("utf8"))
image2.save('python_secrets.png', 'PNG')
image2 = Image.open('python_secrets.png')
data = stepic.decode(image2)
print("Decoded data: " + data)
Beispiel #39
0
#!/usr/bin/python

# need PIL and stepic packages
import Image
import stepic

image1 = Image.open("myimage.png")
steg = stepic.encode(image1, 'This is hidden text firoj')
# steg = stepic.encode(i, text)

steg.save("stegnofied.png", "PNG")

image2 = Image.open("stegnofied.png")
image2.show()

eimage = Image.open("stegnofied.png")
s = stepic.decode(eimage)
data = s.decode()
print(data)
Beispiel #40
0
def encode(pic, stegpic, message):
    im=Image.open(pic)
    im2=stepic.encode(im, message)
    im2.save(stegpic)
    im2.show()
    return stegpic
Beispiel #41
0
import Image
import stepic
import ezPyCrypto
import sys
im=Image.open(sys.argv[1])
im1=stepic.encode(im,sys.argv[2])
im1.save('encoded.png','PNG')
# generating data that will be encoded in index frame
indexData = generateIndexData('abc.java','')

# generaing data frame
data1Loc = generateRandomFrameNo(frameCount, occ)
indexData += str(data1Loc) + ','
data1 = 'Data 1 is the name Jash'

data2Loc = generateRandomFrameNo(frameCount, occ)
indexData += str(data2Loc)
data2 = 'Data 2 is the name VJTI'

# steganography on index frame
img = Image.fromarray(frames[index])
stegimg = stepic.encode(img, indexData)
frames[index] = np.array(stegimg)

# steganography on data frame 1
img = Image.fromarray(frames[index])
stegimg = stepic.encode(img, data1)
frames[data1Loc] = np.array(stegimg)

# steganography on data frame 2
img = Image.fromarray(frames[index])
stegimg = stepic.encode(img, data2)
frames[data2Loc] = np.array(stegimg)

# write image into video
h, w = frames[0].shape[:2]
fps = cap.get(cv2.CAP_PROP_FPS) # Framerate of o/p = i/p
#using stepic
import stepic
import os
from PIL import Image

os.chdir("F:\\graduation-project\\codes")
img=Image.open("exampleimage\\lena.png")
stego=stepic.encode(img,"excited!")
stego.save("output\\another.png")
print(stepic.decode(stego))
Beispiel #44
0
#!/usr/bin/python
__author__ = 'deepam'

import Image, stepic

i = Image.open("new.jpg")
i.show()

steg = stepic.encode(i, "This is some random text i am trying to append")

steg.save("steg.jpg", "JPEG")

i2 = Image.open("steg.jpg")
i2.show()
Beispiel #45
0
from PIL import Image
import stepic

# encryption
im = Image.open("Lenna.png")
im1 = stepic.encode(im, "hi friends")
im1.save("StegoLenna.jpg", "JPEG")
im.show()
im1.show()

# decryption
s = stepic.decode()
data = s.decode()
print data
Beispiel #46
0
    data = {"image": encoded_image,
            "album": album_deletehash,
            "type": "base64"}
    resp = urllib2.urlopen(urllib2.Request(url, json.dumps(data), HEADERS)).read()
    return resp

def get_and_decode_image(img_link):
    resp = urllib2.urlopen(img_link)
    #print resp.content
    img = Image.open(StringIO(resp.read()))
    return decompress(stepic.decode(img))

if __name__ == "__main__":
    text = open(sys.argv[1]).read()
    print text
    encoded_image = stepic.encode(Image.open("hobbes.png"), compress(text))
    output = StringIO()
    encoded_image.save(output, format="png")
    resp = upload_image(output.getvalue())

    resp_data = json.loads(resp)
    #print resp_data

    result = get_and_decode_image(resp_data["data"]["link"])
    print result

def string_generator(size=6, chars=string.ascii_uppercase + string.digits):
    return ''.join(random.choice(chars) for _ in range(size))

#new_img = stepic.encode(Image.open("hobbes.png"), string_generator(10000))
#new_img.save("fancy.png")
#!/usr/bin/python
__author__ = 'kilroy'
#  (c) 2014, WasHere Consulting, Inc.
#  Written for Infinite Skills

# need PIL and stepic packages
import Image, stepic

i = Image.open("bullpuppies.jpg")
i.show()
#  could open a file here
# f = open("myfile", "r")
# text = f.read()

steg = stepic.encode(i, "This is some text")
# steg = stepic.encode(i, text)

steg.save("steg.jpg", "JPEG")

i2 = Image.open("steg.jpg")
i2.show()
Beispiel #48
0
 def save_in_image(self, string, image_file, out_file):
     if out_file[-4:] != ".png":
         show_message("The output file should be a png-image")
     image1 = image.open(image_file)
     image2 = stepic.encode(image1, string)
     image2.save(out_file)
Beispiel #49
0
def encode(filepath, message):
	img = Image.open(filepath)
	stegimg = stepic.encode(img,message);
	stegimg.save(filepath,'PNG')
Beispiel #50
0
#!/usr/bin/python
# use pip to install stepic
# need PIL and stepic packages
import Image, stepic

i = Image.open("unnamed.jpg")
i.show()
#  could open a file here
# f = open("myfile", "r")
# text = f.read()

steg = stepic.encode(i, "i am hidden")
# steg = stepic.encode(i, text)

steg.save("steg.jpg", "JPEG")

i2 = Image.open("steg.jpg")
i2.show()
import stepic

cap = cv2.VideoCapture('sample1.avi')

# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*'DIB ')

# generate all frames
frames = []
while True:
	ret, temp = cap.read()
	if not ret:
		break
	frames += [temp]

index = 42 # <- Index at which our data is hidden (frame no.)
fps = cap.get(cv2.CAP_PROP_FPS) # Framerate of o/p = i/p

# steganography on index frame
img = Image.fromarray(frames[index])
stegimg = stepic.encode(img, 'Index frame data to be encoded!')
frames[index] = np.array(stegimg)

# write image into video
h, w = frames[0].shape[:2]
fourcc = cv2.VideoWriter_fourcc(*'DIB ')
out = cv2.VideoWriter('output.avi', fourcc, fps, (w,h))

for each_frame in frames:
	out.write(each_frame)
Beispiel #52
0
#import required packages and functions
from PIL import Image
import stepic as sp

ans = "Y"
#Asking user for input
while ans != "N" or ans != 'n':
    ed = input("\nPress: 1) E for Encryption 2) D for Decryption ")
    if (ed == "E" or ed == "e"):
        ip = input("\nEnter the image filename: ")  #Image filename
        i = ip.find('.')
        ext = ip[-(len(ip) - i - 1):].upper()  #Getting extension
        text = input("\nEnter the text to encode: ")  #Getting text to encode
        im = Image.open(ip)
        tx = bytes(text, "utf-8")
        im1 = sp.encode(im, tx)  #Encoding text into image
        im1.save(ip, 'PNG')  #Saving image with the same name

        #im1 = Image.open(ip)
        #im1.show()
        #im.show()

    elif (ed == "D" or ed == "d"):  #Decoding
        ip = input("\nEnter the image filename: ")  #Iamge file
        im = Image.open(ip)
        text = sp.decode(im)  #Decoding text
        print("\nDecoded Text: ", text)

    else:
        print("\nPress valid key\n")
        ans = "Y"
# need pycrypto package
from Crypto.Cipher import AES
# need PIL and stepic packages
import Image, stepic
import binascii

# key has to be 16, 24 or 32 bytes long
cryptObj = AES.new("This is my key42", AES.MODE_CBC, "16 character vec")
#  notice the spaces -- that's to pad it out to a multiple of 16 bytes
plaintext = "This is some text we need to encrypt because it's very secret   "
ciphertext = cryptObj.encrypt(plaintext)

#  we need to convert to ASCII to store it nicely
binval = binascii.b2a_base64(ciphertext)
i = Image.open("bullpuppies.jpg")

print("ASCII: ", binval)
stego = stepic.encode(i, binval)
stego.save("stegencrypt.bmp", "BMP")

newim = Image.open("stegencrypt.bmp")
data = stepic.decode(newim).rstrip('\n')

print("What we have out: ", data)
#  convert from ASCII back to binary
encrypted = binascii.a2b_base64(data)

newcryptObj = AES.new("This is my key42", AES.MODE_CBC, "16 character vec")
result = newcryptObj.decrypt(encrypted)

print(result)
Beispiel #54
0
	def gif(self):
		im = Image.open(self.file)
		data = "***" + str(self.sign()) + "***" + self.user + ' ' + self.time
		ime = stepic.encode(im,data)
		ime.save(self.tmp_file,'GIF')
Beispiel #55
0
    def encode_img(self, data):

        im = Image.open('/home/li/dev/anondoge/client/img/01.jpg')
        img = stepic.encode(im, data)
        img.save('doge.png', 'PNG')
Beispiel #56
0
#generate AES key of size 16 bytes
aes_key = get_random_bytes(16)
aes_enc = AES_Encryption(aes_key)

#encrypt file using AES
file_name = sys.argv[-1]
aes_enc.encrypt_file(file_name)

#generate 3DES key of size 16 bytes
des_key = get_random_bytes(16)
des_enc = TripleDES_Encryption(des_key)

#encrypt file using 3DES
des_enc.encrypt_file(file_name + ".enc")

rsa_message = des_key + aes_key
rsa_pvt_key = RSA.generate(1024)
rsa_pub_key = rsa_pvt_key.publickey()
rsa_cipher = PKCS1_OAEP.new(key=rsa_pub_key)
ciphertext = rsa_cipher.encrypt(rsa_message)
print("RSA successfull")

#store keys in an image
folder = r"C:\xampp\htdocs\Mescoe-Cloud\images"
a = random.choice(os.listdir(folder))
file = folder + '\\' + a
im = Image.open(file)
im1 = stepic.encode(im, rsa_pvt_key.export_key() + ciphertext)
im1.save("C:/xampp/htdocs/Mescoe-Cloud/images/keyImage.png", "PNG")
print("LSB successfull")
from PIL import Image
import stepic

im=Image.open('I:/FYP/Lenna.png');
im1=stepic.encode(im,'Hello world')
im1.save('StegoLenna.jpg','JPEG')
im.show()
im1.show()

s=stepic.decode(im1)
data=s.decode()
print data
Beispiel #58
0
from PIL import Image
import stepic as sp

ans = "Y"
while ans != "N" or ans != 'n':
    ed = input("\nPress: 1) E for Encryption 2) D for Decryption ")
    if (ed == "E" or ed == "e"):
        ip = input("\nEnter the image filename: ")
        i = ip.find('.')
        ext = ip[-(len(ip) - i - 1):].upper()
        text = input("\nEnter the text to encode: ")
        im = Image.open(ip)
        tx = bytes(text, "utf-8")
        im1 = sp.encode(im, tx)
        im1.save(ip, 'PNG')

        im1 = Image.open(ip)
        im1.show()
        im.show()

    elif (ed == "D" or ed == "d"):
        ip = input("\nEnter the image filename: ")
        im = Image.open(ip)
        text = sp.decode(im)
        print("\nDecoded Text: ", text)

    else:
        print("\nPress valid key\n")
        ans = "Y"
        continue
def encrypt_image(path, password):
    im = Image.open(path)
    passwd = base64.b64encode(password)
    im1 = stepic.encode(im, passwd)
    im1.save(path,'PNG')