How to encrypt base64_encode and urlencode strings in php _ PHP Tutorial

Source: Internet
Author: User
The base64_encode and urlencode string encryption methods in php. This article introduces the simple encryption of strings using php's ase64_encode and urlencode, which is also a common method, if you need it, please refer to this article. This article introduces the simple encryption of strings using php's ase64_encode and urlencode, which is also a common method, if you need it, please refer to this article.

Base64_decode
Decodes a BASE64 encoded string.

Syntax: string base64_decode (string encoded_data );

Return value: string

Function type: encoding


Description


This function decodes strings encoded with MIME BASE64. The decoded string may be a Chinese string or other binary data.

Example

The code is as follows:
$ Str = 'vghpcybpcybhbiblbmnvzgvkihn0cmluzw = ';
Echo base64_decode ($ str );
?>

Str urlencode ($ string)
This function is a convenient part of URL query when encoding strings. it is used as a convenient way to pass variables to the next page.

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

The code is as follows:
$ Query_string = 'foo = '. urlencode ($ foo).' & bar = '. urlencode ($ bar );
Echo '';
?>

Look at two integrated functions.

The code is as follows:
$ Encryption = "username ";
Echo base64_encode ($ encryption); // echo "dXNlcm5hbWU = ";
Echo"
";
Echo urlencode ("http: //". $ encryption); // echo "http % 3A % 2F % 2 Fusername ";
Echo"
";
Echo sha1 ($ encryption); // echo "249ba36da-29bbe97499c03db5a9001f6b734ec"
Echo"
";
?>

...

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.