PHP code example of random_tool / random_encrypt

1. Go to this page and download the library: Download random_tool/random_encrypt 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/ */

    

random_tool / random_encrypt example snippets


// 依赖注入
use RandomTool\RandomEncrypt;

public function index(RandomEncrypt $encrypt){
    $encrypt->config(['salt' => "salt"]);
    $rs = $encrypt->encrypt("hello world");
    var_dump($rs);
    $s = $encrypt->decrypt($rs[0]);
    var_dump($s);
}
// 静态实例化
use RandomTool\RandomEncrypt;

public function index(){
    $encrypt = RandomEncrypt::init(['salt' => 'salt']);
    $rs = $encrypt->encrypt("hello world");
    var_dump($rs);
    $s = $encrypt->decrypt($rs[0]);
    var_dump($s);
}