iEncrypter is a simple AES encrypt / decrypt sample program using OpenSSL's lib.
The program contains following features:
- Encrypt a file using AES algorithm (Password or key file).
- Decrypt a file using AES algorithm (Password or key file).
- Generate a key file from password.
Well, actually, the key file is just a 32-characters-long MD5 hash value, which is perfect for OpenSSL's AES key.
To use this program, please use the following command:
- Using password:
ien encrypt -i [Input] -o [Output] -p [Password]
For example:
ien encrypt -i "1.txt" -o "2.txt" -p "123456"
- Using key file:
ien encrypt -i [Input] -o [Output] -k [Key Path]
For example:
ien encrypt -i "1.txt" -o "2.txt" -k "key.txt"
- Using password:
ien decrypt -i [Input] -o [Output] -p [Password]
For example:
ien decrypt -i "2.txt" -o "3.txt" -p "123456"
- Using key file:
ien decrypt -i [Input] -o [Output] -k [Key Path]
For example:
ien decrypt -i "2.txt" -o "3.txt" -k "key.txt"
ien genkey -o [Output] -p [Password]
For example:
ien genkey -o "key.txt" -p "123456"
- On Windows: You need
nmake
. - On Unix based systems (Including OSX): You need command
make
to work.- On mac, you can use Homebrew to install
make
. - On Linux, you can use your favorite package manager to install
make
orGNU make
.
- On mac, you can use Homebrew to install
The encryption and decryption uses AES_Encrypt
and AES_Decrypt
. Key gen uses MD5
.
Take AES_Encrypt
for example:
The OpenSSL's aes.h
defines blocks with length of 16
. Which means that all the plaintext and ciphertext must have length no more than 16. Any string longer than 16 will be ignored.
And even though you may get ciphertexts longer or shorter than 16, they are indeed 16 characters. You can use strlen()
to verify that.
Another thing to be noticed: You must memset all the input and output character arrays. Don't ask why, you can try.
Other things such as file operations, they have nothing to talk about. Anyone with some basic knowledge of programming can read them easily (probably).
You may wonder why I wrote this. Well, as you can see, encryption programs like OpenSSL's official CMD tools, they usually contains large amount of codes. It's hard to find a simple program that encrypts and decrypts files.
That's right, this program is written for studying purpose.
This project has inherited the dual OpenSSL and SSLeay license from OpenSSL, I guess.
Or what else, I don't know.