Created
February 24, 2014 20:40
-
-
Save tiran/9196564 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2.7 | |
import os | |
from PIL import Image | |
from Crypto.Cipher import AES | |
# random key | |
key = os.urandom(16) | |
# load image | |
img = Image.open("militarygrade.png") | |
# encrypt | |
cipher = AES.new(key) | |
cdata = cipher.encrypt(img.tobytes()) | |
# create image from encrypted data | |
cimg = Image.frombytes(img.mode, img.size, cdata) | |
cimg.save("militarygrade_encrypted.png") | |
cimg.show() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment