A way to store encrypted data inside a png without altering the image itself.
# encrypt
cryptpng encrypt --image <name of the image> --in <input file> --out <output file>
# decrypt
cryptpng decrypt --image <crypt image> --out <decrypted output file>
It should be possible to store data with a size up to ~ 4GB, but in reality most image viewers have
problems with chunks that are bigger than several Megabytes.
The data itself is stored in a png chunk
and encrypted via aes. The encryption chunk is stored right before the IDAT
chunk that contains the
image data. The steps for encrypting are:
- Parse the png file and split it into chunks.
- Prompt for a password and use the scrypt 32byte value with a generated salt.
- Store the salt in the
saLt
chunk. - Encrypt the data using aes and the provided hashed key.
- Split the data into parts of 1 MiB of size.
- Store every data part into a separate
crPt
chunk. - Write the png header and chunks to the output file.
- Parse the png file and split it into chunks.
- Get the
saLt
chunk. - Get the
crPt
chunks and and concat the data. - Prompt for the password and create the scrypt 32byte hash with the salt.
- Decrypt the data using aes and the provided hash key.
- Write the data to the specified output file.