PHP code example of luler / phpcrypt

1. Go to this page and download the library: Download luler/phpcrypt library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

luler / phpcrypt example snippets

injectablephp
$cleartext = "需要加密的数据";
$cipher = \Php\Crypt\Crypt::encrypt($cleartext, "123456");
echo "\n";
echo '加密后密文:' . $cipher . "\n";
echo '解密后明文:' . \Php\Crypt\Crypt::decrypt($cipher, "123456") . "\n";
//设置秘钥超时失效,只需把expires参数设置有效时间,单位是秒,比如有效期为一分钟,则设置expires为60
$cipher = \Php\Crypt\Crypt::encrypt($cleartext, "123456", 60);
echo '加密后密文:' . $cipher . "\n";
echo '解密后明文:' . \Php\Crypt\Crypt::decrypt($cipher, "123456") . "\n";