Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 465
  • Last Modified:

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

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

0
bearfilms
Asked:
bearfilms
  • 2
  • 2
2 Solutions
 
babuno5Commented:
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 .
0
 
Marcus BointonCommented:
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?
0
 
bearfilmsAuthor Commented:
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.
0
 
Marcus BointonCommented:
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.
0
 
bearfilmsAuthor Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now