PHP crypt() function

The crypt() function returns a hashed string using DES, Blowfish, SHA256, SHA512, or MD5 algorithms

the crypt() function supports multiple hash types : CRYPT_STD_DES, CRYPT_EXT_DES, CRYPT_MD5, CRYPT_BLOWFISH, CRYPT_SHA256, CRYPT_SHA512


crypt ( string $string , string $salt) : string


Parameter Name Descrption
$string Required, The string.
$salt Optional, salt string to base the hashing on.

Return Value

Returns the hashed string

crypt() examples

$password = 'aSASas';
echo crypt($password);
//Output :: $1$bg..I53.$hJmp8U7B4Vq5ysHLb1eZS/

Related Functions

  • sha1(): Calculate the sha1 hash of a string
  • sha1_file(): Calculate the sha1 hash of a file
  • crc32(): Calculates the crc32 polynomial of a string
  • md5(): Calculate the md5 hash of a string
  • md5_file(): Calculates the md5 hash of a given file