Case resolution for cryptographic decryption functions that are owned in PHP

Source: Internet
Author: User
Tags crypt md5 encryption
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

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.