Home  >  Article  >  Backend Development  >  Sharing examples of using encryption and decryption string functions in PHP

Sharing examples of using encryption and decryption string functions in PHP

黄舟
黄舟Original
2017-08-15 10:22:011772browse

In our previous lesson, we introduced the usage tutorial of several methods of php encryption and decryption, we only introduced the encryption and decryption methods in php, so today we are going to give you Detailed explanation of the specific use of the encryption and decryption string functions in PHP introduced!

In our daily project development, sometimes we need to use PHP to encrypt specific information, that is, to generate an encrypted string through the encryption algorithm. This encrypted string can be decrypted through the decryption algorithm to facilitate the program. Process the decrypted information.

Step one: Download the class we need to use PHP encryption and decryption string functions in this chapter: http://www.php.cn/xiazai/leiku/730

Step 2: After completing the download, unzip the file to the local server editor, open the file, and then create a new php file to call the file!

Step 3: Instantiate the class:

<?php
include_once "codezfc.php"; //引入类
//定义字符串
$str=&#39;作者:php.cn&#39;;
$key= &#39;php.cn&#39;;

//对字符串进行加密解密
$encrypt=passport_encrypt($str,$key);
$decrypt=passport_decrypt($encrypt,$key);
echo &#39;原文:&#39;.$str."<br><hr>";
echo &#39;密文:&#39;.$encrypt."<br><hr>";
echo &#39;译文:&#39;.$decrypt."<br><hr>";

Finally run this file and get the following results:

Sharing examples of using encryption and decryption string functions in PHP

The above is the detailed content of Sharing examples of using encryption and decryption string functions in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn