Hello, I just used the crypt command on 'password' and 'password1' and got identical output!! What are the rules concerning the crypt function? Am I not allowed to use numbers? EXACTLY what am I allowed to use? Many thanks in advance.
According to this comment on php.net , certain situations will cause crypt() to only look at the first eight characters.
For example, in this situation, they seem to return the same thing and only compare the first eight characters...
<?php
echo crypt('password', 'blablabla');
echo crypt('password1', 'blablabla');
?> One way to this doesn't happen is to use a md5 hash as the encryption salt. For example, this will automatically generate an md5 hash for the salt, and use that for the encryption (at least the way my server is set up).
<?php
$cypher = crypt( time() );
echo crypt('password', $cypher);
echo crypt('password1', $cypher);
?> That will return two different strings like it is supposed to.
Random question... why use crypt? Why not just check the md5 hash of the password (saved in the db) against the md5 hash of the user input?
- Walkere