The crypt() function in PHP returns a hashed value. It uses the DES, Blowfish, or MD5 algorithms.
It returns the first two characters of the output as salt in DES-based crypt(). As salt parameter is optional but crypt() function gives a weak password without salt.
The following constants are set depending on the availability of given type :
- [CRYPT_STD_DES] : Standard DES-based hash with a two character salt.
- [CRYPT_EXT_DES] : Extended DES-based hash with a nine character salt
- [CRYPT_MD5] : MD5 hashing with a 12 character salt
- [CRYPT_BLOWFISH] : Blowfish hashing with a salt starting with $2a$, $2x$, or $2y$, a two digit cost parameters "$", and 22 characters from the alphabet "./0-9A-Za-z"
Syntax
crypt(str,salt)
In the above syntax the str here specifies the string to be hashed and the salt string to base the hashing on.
for example
<?php
$password = 'mypassword';
$hash = crypt($password);
?>
in the above code the password 'mypassword' is passed to the $hash with the use of the crypto function
0 Comment(s)