Therefore, **we have to ++convert the key/iv in C code to hex digits as a parameter++ when launching openssl binary**. The key point here is the key/iv in C code are strings while in parameter are hex. In this case, I encrypt a file by openssl binary and decrypt it by API imported in my code. # Encryption by binary and decrpytion by API Tomas# openssl aes-128-ecb -d -K 35D447AD8E76F1BFB40F12EAF216ABEB -p -nosalt -pbkdf2 -in cypher.txt -out plain2.txt Tomas# openssl aes-128-ecb -d -k aaaaaaaa -p -nosalt -pbkdf2 -in cypher.txt -out plain.txt
Tomas# openssl aes-128-ecb -e -k aaaaaaaa -p -nosalt -pbkdf2 -in org.txt -out cypher.txt The command is mostly the same including parameters like -K, -k, -iv, -nosalt, -pbkdf2, -iter and so on. # Encryption by binary and decrpytion by binary engine val Use engine, possibly a hardware device writerand outfile Write random data to the specified file
rand val Load the file(s) into the random number generator pbkdf2 Use password-based key derivation function 2 iter +int Specify the iteration count and force use of PBKDF2 md val Use specified digest to create a key from the passphrase A Used with - to specify base64 buffer as a single line a Base64 encode/decode, depending on encryption flag In this case, I encrypt a file in a x86-based system, and decrypt it in a mips-based system which is a switch here.
On the other hand, I will demo **how to encrypt a file through openssl binary and decrypt it through openssl API in c code**. In this note, on one hand, I will show **how to use the openssl binary to encrypt and decrypt a file**. # tags: `development`, `C`, `tool`, `linux`, `AES`, `CBC`, `ECB`, `OpenSSL`, `openssl`, `openssl API`, `openssl binary`, `hexdump`, `od`, `xxd` AES encryption/decryption through OpenSSL API and binary respectively