Shahid Aslam
Shahid Aslam

Reputation: 2585

encryption using PHP crypt

I’m having a problem in encryption using PHP crypt

Following is my code :

echo $ret = crypt('Dave@123','$2y$10$XLLl50bLyTWfjcvCAxwGRu/px2Q.LXN0fHpD1KN2CQCMx/tpL1V62');

1) When using crypt in PHP Version 5.4.22 It results:

 $2y$10$XLLl50bLyTWfjcvCAxwGRu/px2Q.LXN0fHpD1KN2CQCMx/tpL1V62

2) When used with PHP Version 5.2.17 it results

 $25nFTQHtfjVg

I want the same result as 1.

Upvotes: 2

Views: 145

Answers (2)

Sanoob
Sanoob

Reputation: 2474

From the manual. I came to know that they introduced Update $2y$ Blowfish modes on 5.3.7. So in PHP 5.2.17 you may get DES. The type of hashing is decided from the salt you provides.

Upvotes: 1

TimWolla
TimWolla

Reputation: 32681

The issue is the 2y blowfish prefix. It was introduced after a security issue in PHP 5.3.7 and so PHP 5.2 does not know about it, sees an invalid $salt and generates an invalid hash.

The equivalent in PHP 5.2 is 2a, but it might be affected by the mentioned security issue (I did not check).

Upvotes: 1

Related Questions