Gossamer Forum
Home : General : Internet Technologies :

PHP crypt()

Quote Reply
PHP crypt()
Mmm..this is weird!

Using this;

Code:
<?php

$word = "dfsmething@sfdfgdfgfsf.com.ufk";
$code = crypt("MM", $word);

echo $code;

?>

Returns;

dfaVtLshRfT5E

And changing;

$word = "dfsmething@sfdfgdfgfsf.com.ufk";

to

$word = "dfsmething@sfdfgdfgfsf.com.uk";

(not the ufk is changed to uk) gives me;

dfaVtLshRfT5E

Why?

Shouldn't they be different, as they are different words? Does the crypt() function only generate up to 13 char encrypted words?

Thanks

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] PHP crypt() In reply to
MD5-based crypt() uses an 8-character salt.
Quote Reply
Re: [Paul] PHP crypt() In reply to
Ah..I see. All I need it for is to create a random password for people signing up to my site. I'm going to use their username to create a random password with either MM, or another random salt. Now I gott work out what I'm gonna use for the username :p

Thanks

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] PHP crypt() In reply to
The crypt() function is DES based and only works off the first 8 chars of a password:

[alex@penguin ghost]$ perl -le 'print crypt("12345678", "aa")'
aaNN3X.PL2piw
[alex@penguin ghost]$ perl -le 'print crypt("123456789", "aa")'
aaNN3X.PL2piw
[alex@penguin ghost]$

If you are looking for more secure password encryptions, try using an md5 based encryption. It's Digest::MD5 in Perl, not sure what it would be in php. =)

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Andy] PHP crypt() In reply to
Oh, also, you've got your arguments backwards I think:

$code = crypt("MM", $word);

should probably be:

$code = crypt($word, "MM");

where "MM" is a randomly generated salt string. I think PHP provides this for you if you don't specify it, so:

$code = crypt($word);

should be fine.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] PHP crypt() In reply to
Ah..I see. I was only really looking at using the email address as a wqay to make a random looking password (rather than using rand() with a sdpecific selection of chars...)

Thanks Smile

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Alex] PHP crypt() In reply to
In Reply To:
Oh, also, you've got your arguments backwards I think:

$code = crypt("MM", $word);

should probably be:

$code = crypt($word, "MM");

where "MM" is a randomly generated salt string. I think PHP provides this for you if you don't specify it, so:

$code = crypt($word);

should be fine.

Cheers,

Alex

Nah..my way is right. PHP does everythin backwards to Perl Wink

I thought it was the other way first, but it seems that its not.

Thanks

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] PHP crypt() In reply to
Are you sure? PHP.net seems to say otherwise:

http://www.php.net/...n/function.crypt.php

Crazy language. =)

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] PHP crypt() In reply to
Yeah, but it doesn't seem to work the other way Unimpressed Weird!

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] PHP crypt() In reply to
Did you look at the examples?

You can leave out the salt as Alex suggested.