PHP encryption function Md5,crypt,base64_encode and other usage introduction

Source: Internet
Author: User
Tags crypt php define urlencode
The irreversible cryptographic functions are: MD5 (), Crypt ()
MD5 () is used to calculate MD5. The syntax is: string MD5 (string str);
Crypt () encrypts the string with the UNIX standard cryptographic 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 parameter, and then the encrypted string. The syntax is: string crypt (String str, string [salt]);
Reversible encryption: Base64_encode (), UrlEncode () corresponding decryption function: Base64_decode (), UrlDecode ()

Base64_encode () encodes the string in MIME BASE64. This encoding allows Chinese text or pictures to be transferred smoothly on the network. The syntax is string Base64_encode (string data); Its decryption function is: string Base64_decode (string encoded_data); Will be returned as is
UrlEncode () encodes the string as a URL. For example, a space will become a plus sign. The syntax is: string UrlEncode (String str);
Its decryption function is: string UrlDecode (String str); Will be returned as is

See section Code:

<?php define ("str", "Mo Jian"); The result of ECHO ' MD5 encryption is: '. MD5 (str). ' <br> ';//md5 encryption echo ' Crypt encryption results in: '. Crypt (str,str). ' <br> ';//Crypt Encryption $base 64encode=base64_encode (str);//Base64_encode () encryption echo ' Base64_encode encryption result is: '. $ Base64Encode. ' <br> '; The result of Echo ' Base64_decode decryption is: '. Base64_decode ($base 64encode). ' <br> '; Base64_decode () decryption $urlencode =urlencode (str); UrlEncode () The result of encrypting echo ' UrlEncode encryption is: '. $urlencode. ' <br> '; The result of Echo ' UrlDecode decryption is: '. UrlDecode ($urlencode). ' <br> ';//urldecode () Decrypt?>

The result of the output is:
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.