PHP code example of youthage / laravel-3des

1. Go to this page and download the library: Download youthage/laravel-3des 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/ */

    

youthage / laravel-3des example snippets


composer 

config文件夹下创建baseconfig.php

内容



return [

    'DES3_KEY' => 'ABCDEFGHIJKLMNOPQRSTUVWX',
    
    'DES3_IV' => '12345678',

];



namespace App\Http\Controllers;

use DES3;
class IndexController extends Controller
{
    public function index()
    {
        // 加密
        $encrypt = DES3::encrypt(111);
        echo $encrypt;

        // 解密
        $decrypt = DES3::decrypt($encrypt);
        echo $decrypt;
        
        // 动态使用
        DES3::encrypt(111, 'ABCDEFGHIJKLMNOPQRSTUVWX', '12345678');
        DES3::decrypt($encrypt, 'ABCDEFGHIJKLMNOPQRSTUVWX', '12345678');
    }
}