-3

I am wanting to take a currently base64 encoded image and use a short hash say "84dskh" to "encrypt" the image into another perfectly valid base64 encoded image.

The original image does not have to be base64 encoded, ultimately I want a encrypted image of the original, but have it still be a valid image I could display in a img tag: <img src="myimage" />.

Preferably using javascript.

  • 3
    Great! What have you tried so far and where are you stuck? – Marvin Feb 11 '16 at 23:20
  • Well I have tried rearranging the values of the base64 encoded string. But I end up with an invalid string that cannot be displayed in the browser. I know I can just "encrypt" the image, but then a image won't show up in the browser if I do that. – Yellow-pelican-087 Feb 12 '16 at 15:42

1 Answers1

2

To encrypt the image, you would save it as a string (there may be limits there), and then when loading the image into the HTML document, use a decrypt method. Here is a related question. You may also find this library helpful (suggested within an answer).

Community
  • 1
  • 1
Matthew Spence
  • 986
  • 2
  • 9
  • 27
  • I am not trying to encrypt per say. More like scramble. I want to "scramble" the image so that is unrecognizable. Then client side in the javascript I want to "unscramble" the image when a user clicks a button. They will go from seeing a image of pixelated junk, to the actual photo. – Yellow-pelican-087 Feb 12 '16 at 15:44
  • So effectively swap sections of the image around? – Matthew Spence Feb 12 '16 at 15:48
  • That would work, as long as the "swapped" image could still be displayed. – Yellow-pelican-087 Feb 12 '16 at 15:59
  • I'm afraid I do not know how this would be achieved, perhaps a new question entirely? Here is the only [resource](https://github.com/dantarakan/Image-Scramble) I have found with any real relevance. – Matthew Spence Feb 12 '16 at 21:03