For e-commerce site users, the most important thing is the security of the account and password, if the account and password is not encrypted processing, will greatly increase the security risks, never let criminals open the way, so now the website development in order to ensure that the interests of users and privacy is not compromised, the user's account password to encrypt, In this chapter, we will take you to know how to encrypt and decrypt the password.
First we need to know that our password is a string, and the base64 encoding and decoding of the string can be implemented by PHP's pre-defined functions Base64_encode () and Base64_decode ().
Base64_encode () function
The base64 encoding of the character is implemented with the function Base64_encode (), with the following syntax:
Base64_encode (str);
This function implements the base64 encoding of the string str.
Base64_decode () function
We use the Base64_decode () function to decode a string with the following syntax:
Base64_decode (str);
Also function implementation to decrypt a string that has been base64 encoded
Two functions we have already introduced, so how exactly is it used? Look at the following example
Application examples
By the String function Base64_encode (), Base64_decode () to encrypt and decrypt the password, we encrypt the user's password and decrypt the code as follows:
<! DOCTYPE html>
When the "Submit" button is clicked, the password is encrypted and decrypted by the string function Base64_encode (), Base64_decode (), and the result is as follows:
PHP provides a lot of encryption and decryption functions, such as base64_encode () or MD5 (), etc., can be used in the actual use of a suitable function to choose the use. Read more about the PHP cryptographic functions topic