views:

199

answers:

3

Is there a way in PHP 5.3 to get crypt() blowfish (salt starting with $2a$) results identical to those generated by PHP 5.2? In 5.3, Zend implements all encryption algorithms internally, thus producing different results. Also, in 5.3, blowfish needs a cost parameter.

Basically, is there a way to call whatever system mechanisms were used for encryption in PHP 5.2 using a command line program?

Note: The server is on Linux, must be distro portable.

A: 

Perhaps via mcrypt?

Amber
Possibly, but I'd need to know all of the parameters that crypt() used in PHP 5.2, as well as how the salt is applied to the cipher text.
Shadow
A: 

No matter which PHP version you using the crypt(); function will produce the same result. Because its a AES implementation

streetparade
Sorry, but that's simply incorrect, both according to the documentation and by my own experimentation. You can choose from several different algorithms based on certain key characters in the passed salt.
Shadow
+1  A: 

The internal implementations are supposed to be completely compatible with the external OS implementations.

Presumably the OS implementation (libxcrypt?) has a default value for the cost parameter if none is supplied - you'll just have to track down what that is!

caf
Upon further investigation, I found out the old server (running 5.2) didn't have Blowfish capability, so when I copied the code to my test server (which doesn't have system blowfish, but does have Zend's blowfish since it's running 5.3), it was giving me actual blowfish results. Marked as answer since you made me investigate more. Thanks.
Shadow