PHP encryption function Md5,crypt,base64_encode and other use introduction _php skills

Source: Internet
Author: User
Tags crypt md5 md5 encryption urlencode
The irreversible cryptographic functions are: MD5 (), Crypt ()
MD5 () is used to compute MD5. Syntax is: string MD5 (string str);
Crypt () encrypts the string with the standard UNIX encryption DES module. This is a one-way cryptographic function that cannot be decrypted. To compare strings, place the first two characters of the encrypted string in the salt's parameters, and then compare the encrypted string. Syntax is: string crypt (String str, string [salt]);
Reversible encryption is: Base64_encode (), UrlEncode () corresponding to the decryption function: Base64_decode (), UrlDecode ()

Base64_encode () encodes the string in MIME BASE64. This encoding allows Chinese characters or images to be transmitted smoothly on the network. Syntax is string Base64_encode (string data); Its decryption function is: string Base64_decode (string encoded_data); will return to the original
UrlEncode () encodes the string as a URL. For example, a space will become a plus sign. Syntax is: string UrlEncode (String str);
Its decryption function is: string UrlDecode (String str); will return to the original

Read paragraph code:
Copy Code code as follows:

<?php
Define ("str", "Mo Jian");
The result of the Echo ' MD5 encryption is: '. MD5 (str). ' <br> ';//MD5 encryption
The result of the Echo ' Crypt encryption is: '. Crypt (str,str). ' <br>/Crypt Encryption
$base 64encode=base64_encode (str);//Base64_encode () encryption
The result of the Echo ' Base64_encode encryption is: '. $base 64encode. ' <br> ';
The result of the Echo ' Base64_decode decryption is: '. Base64_decode ($base 64encode). ' <br> '; Base64_decode () decryption
$urlencode =urlencode (str); UrlEncode () encryption
The result of the Echo ' UrlEncode encryption is: '. $urlencode. ' <br> ';
The result of the Echo ' UrlDecode decryption is: '. UrlDecode ($urlencode). ' <br> ';//urldecode () decryption
?>

The results of the output are:
The result of MD5 encryption is: EA796AF15C74E90FAEBA49576FA7984B
The result of crypt encryption is: Ink Ylczgttyxps
The result of Base64_encode encryption is: xku9ow==
The result of Base64_decode decryption is: Mo Jian
The result of UrlEncode encryption is:%C4%AB%BD%A3
The result of UrlDecode decryption is: Mo Jian

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.