CryptoJS is said to be OpenSSL compatible what can be noticed running the demo.
Now I want to implement the same behavior using the OpenSSL EVP API: chipher a string using a passphrase and exchange the result with CryptoJS which must be able to decrypt it (knowing the passphrase).
My doubt is about the standard way to exchange the iv (which I see as the key of CryptoJS and OpenSSL compatibility).
How am I supposed to send the iv along with the ciphered message?
PS: Please do not concern about client-side encryption/decryption because I am comfortable with the use case.
Update
Ciphering with OpenSSL command line tool
$ echo "Hello World" | openssl enc -aes-256-cbc -pass pass:"Secret Passphrase" -e -base64
U2FsdGVkX18Z8dTy1NR6/gm+9IxmbuT8iCblIjvV76E=
Deciphering with CryptoJS
var de = CryptoJS.AES.decrypt("U2FsdGVkX18Z8dTy1NR6/gm+9IxmbuT8iCblIjvV76E=","Secret Passphrase",{keySize: 256/32});
de.toString(CryptoJS.enc.Utf8); // output: Hello World
In my use case I want to cipher using the EVP API instead of openssl command line tool. I am missing how to "package" the ciphered text, iv and salt altogether in one string as it was on "U2FsdGVkX18Z8dTy1NR6/gm+9IxmbuT8iCblIjvV76E="
Update 2
I took the Saju Pillai example as start point.
Update 3
My problem is about "interchangeability" of the ciphered text. I am getting the following parts
- key : 79A38D896D90DBFE5E151A326602BC3A4A9081F3F9BEAC08EF058B96BA51CF19
- iv : 76614325D3DA73698DDD220431AE298E00000000000000000000000000000000
- cipher text: QfCKTtVPlDcTOhC5ylwKFQ==
I am looking to send a single string to the client which must be able to decipher the string and get the parts required to the decryption process (it is exactly what I observe between CryptoJS and OpenSSL)