Encrypt .ppm file with AES-ECB to show ECB will reveal patterns
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
#!/bin/sh | |
# This is part of my blog about AES: https://medium.com/p/7616beaaade9 | |
# Inspired by https://blog.filippo.io/the-ecb-penguin/ | |
# Convert your image to .ppm with Gimp or Photoshop | |
# | |
# Usage: ./ecb_img <image file as ppm> <password> | |
# extract header and body | |
head -n 4 $1 > $1.header.txt | |
tail -n +5 $1 > $1.body.bin | |
# encrypt with ecb and given password | |
openssl enc -aes-128-ecb -nosalt -pass pass:"$2" -in $1.body.bin -out $1.body.ecb.bin | |
# reassemble image | |
cat $1.header.txt $1.body.ecb.bin > $1.ecb.ppm | |
# Clean up temp files | |
rm $1.header.txt | |
rm $1.body.bin | |
rm $1.body.ecb.bin | |
echo "encrypted image to $1.ecb.ppm" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe it should be something like this: