PEAR Crypt_Blowfish returns different values on different machines with same key?

Posted on 2008-10-08
Last Modified: 2013-12-12
I have a script running on my production server that uses PEAR Crypt_Blowfish (1.0.1) to encrypt/decrypt passwords.  I'm in the process of moving to new server hardware and am having problems with the new system being able to decrypt the passwords that were encrypted by the old.

On both systems I use the same key and the same function's code to encrypt/decrypt.

Since I'm using the same key on both systems shouldn't I be seeing the same values being returned regardless of the system, or does Blowfish use elements in the encryption that are unique to each installation?

I appreciate any help you can provide, thanks!

//(BCK is the constant containing the crypt key I use.)
    $result = '';
    $crypt = new Crypt_Blowfish(BCK);
    if ('DECRYPT' == $action)
        $result = trim($crypt->decrypt(pack('H*', $pw)));
    else if ('ENCRYPT' == $action)
        $result = bin2hex($crypt->encrypt($pw));
    return $result;

Open in new window

Question by:bearfilms
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 15

Assisted Solution

babuno5 earned 25 total points
ID: 22676211
the only difference that i can see is that the package uses the mcrypt extension if it is installed which might be causing the difference.

That is one server having the mcrypt extension installed and the other will not be having it.

To check just ensure that both the servers either have mcrypt installed or both the servers do not have it installed .
LVL 25

Expert Comment

by:Marcus Bointon
ID: 22677009
Is there any other difference between your servers? e.g. is one 32-bit and the other 64? Or possibly switching endianness, e.g. i386 to PPC or SPARC?

Author Comment

ID: 22678956
Thanks for the comments!  

@ babuno5: I checked and neither machine has mcrypt installed.  That was one of the nice things about using  the PEAR package is that we were able to do encryption without that extension.

@ Squinky: I'm checking with my hosting company to be sure, but doing a uname -m on both machines tells me that the "old" one is i386 and the "new" is i686.  I'm not sure how to find out more detail from the command line so I'll have to wait to hear back from the host to be sure.  We've had the "old" server a long time and my recollection is that it's a P4 while the "new" one is either a dual- or quad-core Xeon.
LVL 25

Accepted Solution

Marcus Bointon earned 100 total points
ID: 22679631
i686 is still 32-bit. 64-bit systems tend to report x86_64 in uname. Main reason for wanting 64-bit is if you have more than about 3.5Gb or RAM. Anyway, it sounds like that factor has essentially not changed.

Have you tried installing mcrypt? It should give an enormous speed boost if you're using this function much, and generally all you'd need to do is 'aptitude install php5-mcrypt' (or equivalent) or alternatively 'pecl install mcrypt' to build it yourself.

Aside from that, it's worth posting a bug report or query on the pear forums/lists.

Author Comment

ID: 22694936
Thanks for the comments.  I've been over and checked the PEAR forum and found that people have had a similar problem and were advised to upgrade to the newest version.  At this point I think I'm just going to create a separate field in the database, convert the passwords and just switch over to the new hardware.

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question