Link to home
Start Free TrialLog in
Avatar of merimax
merimax

asked on

blowfish convert from php to C with openssl

I have a very simple PHP script decrypting strings the way I need it to. It is as follows:

$p="password.sample" ;
$i="MCtwzLQuwdQdhwhciKlhORtKO5K8g8HhA7JGMfpxs41Wtct7lVwHKw==" ;
$blowfish = new Crypt_Blowfish($p);
$output = $blowfish->decrypt(base64_decode($i));

I am trying to accomplish the above in C using openssl/blowfish but I am not able to get the correct combination of arguments set to make this happen. What would be the proper way to accomplish the above in C (linux) and openssl?
ASKER CERTIFIED SOLUTION
Avatar of F. Dominicus
F. Dominicus
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This Q is duplicate(rather renew) of https://www.experts-exchange.com/questions/26932519/openssl-blowfish-decryption.html
The comments You proposed to accept are merely C encryption tutorials, but do not explain the PHP - C differences in algo.
I would advise to delete it instead of forcing accept.
There is but one difference. PHP used an Object interface whereas you have to use the C interface on the C side. However AFAIKT all bigger c packages often used an opaque data pointer as first parameter and IIRC this is done in OpenSSL also.

Regards
Friedrich
fridom: I tried to decrypt the message with openssl  and mcrypt - failed at all combinations. I also googled somewhere the information, that the incompatibility is because of different padding (and possibly IV calculation) used by php and openssl.
IMHO answer to this Q is showing the implementation differences, hence I gave up on that.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.