Solved

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

Posted on 2008-10-08
5
449 Views
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

0
Comment
Question by:bearfilms
  • 2
  • 2
5 Comments
 
LVL 15

Assisted Solution

by:babuno5
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 .
0
 
LVL 25

Expert Comment

by:Squinky
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?
0
 

Author Comment

by:bearfilms
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.
0
 
LVL 25

Accepted Solution

by:
Squinky 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.
0
 

Author Comment

by:bearfilms
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.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now