Irreversible encryption functions: md5 (), crypt ()
Md5 () is used to calculate MD5. Syntax: string md5 (string str );
Crypt () encrypts the string with the standard DES module of UNIX. This is a one-way encryption function and cannot be decrypted. To compare the string, place the first two characters of the encrypted string in the salt parameter, and then compare the encrypted string. Syntax: string crypt (string str, string [salt]);
Reversible Encryption: Corresponding decryption functions of base64_encode () and urlencode (): base64_decode () and urldecode ()
Base64_encode () encodes the string with MIME BASE64. This encoding method enables smooth transmission of Chinese text or images over the network. The syntax is string base64_encode (string data); its decryption function is: string base64_decode (string encoded_data); returns the original
Urlencode () encodes the string into a URL. For example, a space is changed to a plus sign. Syntax: string urlencode (string str );
Its decryption function is: string urldecode (string str); returns the original
Code:
Copy codeThe Code is as follows:
<? Php
Define ("str", "");
Echo 'md5 encrypted result: '. md5 (str).' <br> '; // md5 encrypted
Echo 'crypt encrypted result: '. crypt (str, str).' <br> '; // crypt encrypted
$ Base64encode = base64_encode (str); // base64_encode () Encryption
Echo 'base64_encode: '. $ base64encode.' <br> ';
Echo 'base64_decode: '. base64_decode ($ base64encode).' <br> '; // base64_decode () Decryption result
$ Urlencode = urlencode (str); // urlencode () Encryption
Echo 'urlencode: '. $ urlencode.' <br> ';
Echo 'urldecode: '. urldecode ($ urlencode).' <br> '; // urldecode () Decryption result
?>
The output result is:
The md5 encryption result is: ea796af15c74e90faeba49576fa7984b.
The encrypted result of crypt is: moylczgttyxps.
Base64_encode: xKu9ow =
Base64_decode: the decrypted result is: Mo Jian
Urlencode encrypted result: % C4 % AB % BD % A3
After urldecode is decrypted, the result is: Mo Jian.