Base64_encode and UrlEncode string encryption methods in PHP _php tutorial

Source: Internet
Author: User
This article introduced about the use of PHP Ase64_encode and UrlEncode to the string for simple encryption, is also a more common method, the need for students to refer to this article Oh.

Base64_decode
Decodes the BASE64 encoded string.

Syntax: String Base64_decode (string encoded_data);

return value: String

Function type: Encoding processing


Content Description


This function is decoded as a MIME BASE64 encoded string. The decoded string may be a Chinese string or other binary data.

Cases

The code is as follows Copy Code
$str = ' vghpcybpcybhbiblbmnvzgvkihn0cmluzw== ';
echo Base64_decode ($STR);
?>

Str UrlEncode ($string)
This feature is handy for encoding strings when you want to pass variables to the next page as part of the URL's query as a convenient method.

I wrote this simple function to create a Get query URL () from an array:

The code is as follows Copy Code
$query _string = ' foo= '. UrlEncode ($foo). ' &bar= '. UrlEncode ($bar);
Echo ';
?>

Look at a two comprehensive function.

The code is as follows Copy Code
$encryption = "username";
echo Base64_encode ($encryption);//echo "dxnlcm5hbwu=";
echo "
";
echo UrlEncode ("http://". $encryption);//echo "Http%3a%2f%2fusername";
echo "
";
Echo SHA1 ($encryption);//echo "249ba36000029bbe97499c03db5a9001f6b734ec"
echo "
";
?>

http://www.bkjia.com/PHPjc/629677.html www.bkjia.com true http://www.bkjia.com/PHPjc/629677.html techarticle This article introduces the use of PHP Ase64_encode and UrlEncode to the string for simple encryption, is also a more common method, there is a need for students to refer to this article Oh ...

  • 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.