1

I have a task in which I need to encrypt an image, but the result also has to be a viewable image. My first thought when doing this was to extract the RGB values of each pixel, encrypt them, and create an image with the result. The problem is I can't find a cryptographically secure way to encrypt ints to ints with a given passphrase. Is there a better way to do it? Or is there a way to encrypt 32 bit values to result in 32 bit values?

3
  • 1
    I think what you want is obfuscation, not encryption. As @AtSymbolCarrot mentioned, you could hide the encrypted image data in the LSBs of the "cover" image. The encrypted data needs to have a smaller file size compared to the "cover" image.
    – Vinayak
    Commented Jan 21, 2017 at 12:08
  • What you are looking for is "stenography".
    – phk
    Commented Jan 21, 2017 at 12:15
  • 3
    Close, it's steganography. Steno is shorthand.
    – J.A.K.
    Commented Jan 21, 2017 at 14:16

3 Answers 3

1

I can't find a cryptographically secure way to encrypt ints to ints with a given passphrase

Most encryption algorithms, both symmetric and assymetric use integers. The problem is usually converting other datatypes to int.

If you were to encrypt it, and put it back as an image, it would look like this:

enter image description here

I think what you're looking for is steganography:

Whith this you can hide any file (images too) inside an image. The image will still be viewable but hide data in small color offsets.

Here are some open source tools to do this.

http://sourceforge.net/projects/steghide/files/

http://sourceforge.net/projects/crypture/

http://sourceforge.net/projects/openstego/files/

But this is just the hiding part, encrypting can be done on a unix system with GPG:

gpg --output doc.gpg --symmetric doc
4
0

One thing you can do is take the original picture (P) and a final equally sized picture (E), then XOR them (P⊕E) which will equal a key (K). Now anyone with K and E can XOR them to get the original image (P). Image E can be a publicly available picture, then you can use public key encryption to securely send K and the location of the image to anyone who needs to get P.

5
  • 1
    This is not a good idea at all. It's basically the same as a running key cipher but with image data instead of text. And running key ciphers are weak. Commented Apr 21, 2017 at 21:33
  • Actually, it has perfect secrecy since the image acts as a one time pad. The reason "running key ciphers" are insecure is that crypt-analysis is possible on text, it is not feasible on an image. Explain how you would go about getting the original image, given the publicly available image (assuming you don't have the key). It is impossible. Commented Apr 21, 2017 at 22:07
  • 2
    If it ain't a uniform random bitmap. it ain't a one-time pad. Publicly available images are not random, because real-life images have all sorts of statistical regularities—that's why image compression is so efficient in real life. And you have the burden of proof backwards; you're supposed to argue for the security of your scheme, not demand that others find weaknesses. Commented Apr 21, 2017 at 22:42
  • Also, note that what you call the "key" K = P⊕E is in fact the ciphertext, and the public image E is in fact the key. K is the value in your scheme that's (a) a function of the plaintext P and a shared secret value E, that (b) the sender would have to communicate to the recipient over a non-confidential channel and (c) that the attacker would eavesdrop on. So your proposed challenge—recovering P from just E—amounts to recovering plaintext from knowledge of the key but no ciphertext, which is impossible but of course also meaningless. Commented Apr 21, 2017 at 22:47
  • It is not meaningless, it is the whole point. Without the key it is impossible to recover the plaintext (aka the original image). As long as the original image and the key (or ciphertext) is kept secret, it is secure. As for communicating the ciphertext, that is a matter of choosing a protocol which was never part of the original question. What is meaningless is the differentiation between key and ciphertext. As for statistical regularity in images, crypt-analysis on text running key ciphers attempts to find intelligible portions through brute force, this doesn't work on images. Commented Apr 24, 2017 at 13:59
0

Does something like this not work?: http://www.wikihow.com/Hide-a-File-in-an-Image-File

Or are you trying to get the encrypted output to result in a different image? You could do some steganography using least significant bit to hide the image file. There is a Python program to do so here: https://github.com/RobinDavid/LSB-Steganography. You'd have to encrypt the image file first though.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .