PHP uses base64 for encryption and decryption

Source: Internet
Author: User
PHP uses base64 for encryption and decryption & nbsp; base64 for encryption and decryption in php: & nbsp; base64_encode () and base64_decode () for encryption and decryption. & nbsp; & n PHP implements encryption and decryption with base64
Php uses base64 for encryption and decryption: base64_encode () and base64_decode () for encryption and decryption.


Syntax: string base64_encode (string data)

Use base64 to encode data. This encoding is designed to enable binary data to be transmitted through a non-pure 8-bit transport layer, such as the subject of an email.

Base64-encoded data takes up about 33% more space than raw data.

Syntax: string base64_decode (string encoded_data)
Base64_decode () decodes encoded_data and returns the original data. if it fails, FALSE is returned. The returned data may be binary.


Example 1. base64_encode () example
$ Str = 'This is an encoded string ';
Echo base64_encode ($ str );

?>

This example will show:
VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw =


Example 2. base64_decode () example

$ Str = 'vghpcybpcybhbiblbmnvzgvkihn0cmluzw = ';
Echo base64_decode ($ str );

?>

This example will show:
This is an encoded string

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.