This article brings you the content is about PHP has a cryptographic decryption function case analysis, there is a certain reference value, a need for friends can refer to, I hope you have some help.
PHP's own cryptographic functions
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 re-returned as it 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
PHP Cryptographic decryption function Case code:
<?php define (' str ', ' moqiang02@sina.com '); 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: ' . $base 64encode. ' <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 ?>
Output:
The result of MD5 encryption is: 0C4CF10F2E489A6E6482DB13DFAFAAB8
The result of Crypt encryption is: MOMAPVME.49DQ
The result of Base64_encode encryption is: bw9xawfuzzayqhnpbmeuy29t
The result of Base64_decode decryption is: moqiang02@sina.com
The result of UrlEncode encryption is: moqiang02%40sina.com
The result of UrlDecode decryption is: moqiang02@sina.com