What is difference between CRYPT() and MD5()?

4.4k views Asked by At

When we use CRYPT() method of any variable.

$test = 'password';

echo CRYPT($test);

Result

$1$g9s9ZdtF$sBBiBc4PdljOL4sDLx4CK.

When we use MD5() method of same variable.

$test = 'password';

echo MD5($test);

Result

5f4dcc3b5aa765d61d8327deb882cf99

Now, what is difference in both Answer?

1

There are 1 answers

0
lathspell On

crypt() is a function that creates password hashes from plaintext and a (randomly generated or provided) salt value. It can use several underlaying hash algorithms like DES, MD5, Blowfish or SHA.

Using a "salted" password means that the same plaintext input does not always produce the same hash. So you can't say "I've seen this hash before it's the one for 'abc123'".

As it's available in libc there are crypt() functions in almost all programming languages and database servers so its very interoperable. How secure it is only depends on the hash algorithm you chose (specified in as part of the hash).

For more information see https://en.wikipedia.org/wiki/Crypt_(C)