Summary of commonly used cryptographic functions in PHP

Source: Internet
Author: User
Tags crypt md5 encryption sha1 sha1 encryption urlencode

$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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.