$var= 123; /** * MD5 encryption (single encryption, irreversible) * param $var variables (int\float\string\bool\null) that require encryption, resource type (Resource), and composite type (AR Ray\object) Non-encrypted * param false: Encrypted to 32-bit (default), true: encrypted to 16-bit (garbled problem can be handled by string interception) * Return encrypted value*/ $MD 5=MD5($var,false); Echo $MD 5; /** * Crypt encryption (single-entry encryption, irreversible), the difference from MD5 is that there is a disturbance value * param $var need to encrypt the variable (int\float\string\bool\null), the resource type (Resource) and the composite class Type (Array\object) non-encrypted * param $var 2 interference value, if it is empty will notice, and each refresh PHP will automatically increase the disturbance value * Return encrypted value*/ $crypt=Crypt($var); Echo $crypt; /** * SHA1 encryption (single encryption, irreversible), the difference from MD5 is that by default, a hash value of 40 characters is returned * MD5 (SHA1 ($VAR)) can be combined to encrypt, improve the security of the data
*/ $sha 1=SHA1($var,false); Echo $sha 1; /** * UrlEncode encryption (bidirectional, reversible) is mainly encrypted URL * UrlDecode decryption*/ Echo UrlEncode(' http://www.baidu.com '); /** * Base64_encode encryption (bidirectional, reversible) variable (int\float\string\bool\null), Resource type (Resource) and composite type (array\object) not encrypted * Base64_de Code decryption*/ Echo Base64_encode($var); /** * Resource type (Resource) and composite type (Array\object) are not encrypted, but can generally be encoded by serializing serialize () and then encrypted, Unserialize (): Deserialization*/
Summary of commonly used cryptographic functions in PHP