Page 1 of 1

crypt() problems

Posted: Mon Jul 01, 2002 1:38 pm
by miro
Hi,

I am trying to encrypt a string using DES (yes, I know it's insecure, but I need to use it for compatibility with my MUD's savefiles). If I do a call like this:

$encrypted = crypt($login_pass, substr($login_pass, 0, 2));

$encrypted is equal to the salt plus some encrypted string.

This isn't a bug with the crypt() function on my system, as this all works fine from C. I suspect it has something to do with how I'm passing the arguments.

Thank you for any help.

Posted: Mon Jul 01, 2002 2:14 pm
by martin
Are you sure $login_pass has a value, try echoing it out before your crypt call to make sure it's set.

problem?

Posted: Mon Jul 01, 2002 2:19 pm
by llimllib
As far as I can see, the function works in PHP exactly as it does in Cygwin's crypt() function, i.e:
$login_pass = "doggie";
$salt = substr($login_pass, 0, 2);
$encrypted = crypt($login_pass, $salt);
print $encrypted
yields the same as
crypt do doggie
does in Cygwin. both return do4L9dKP87bPQ

Posted: Mon Jul 01, 2002 2:42 pm
by allevon
I think this may help:

$Password = substr(md5("phpcryptcamp".$Password),0,10);

Posted: Mon Jul 01, 2002 2:45 pm
by miro
Ahh, I see... I haven't been using crypt() correctly at all (the way that my MUD stores passwords is way different than how I thought they did). So looks like the fault was on my end. :wink:

But thanks y'all for your help. :)