views:

303

answers:

3

The not-yet-commons SLL package for Java provides an OpenSSL object with a method for password based encryption:

encrypt("des", password, data);

This method is said to be compatible with the OpenSSL C library. My question is, what is the OpenSSL C++ method equivalent to the above Java?

Thanks

A: 

The EVP cipher functions look like the closest parallel.

Chris Jester-Young
I assume from what I have read that the EVP methods are the best way to use OpenSSL. But what OpenSSL mode/cipher is the not-yet-commons OpenSSL Java object compatible with? I know that there is overlap between the Java and OpenSSL, but I do not know what methods/modes create compatible encryptions, and I'm pretty new to this area anyway.
+1  A: 

Not-Yet-Commons-OpenSSL's ciphers are compatible with "openssl enc" command. Your example can be decrypted by this command,

  openssl enc -k password -a -d -des -in data.file

You can copy the code from the source,

http://cvs.openssl.org/fileview?f=openssl/apps/enc.c&v=1.45.2.5

ZZ Coder
A: 

OpenSSL.encrypt() produces base64 output by default. Use OpenSSL.encrypt(alg, pwd, data, false) to turn that off.

Julius Davies