This commit is contained in:
knowpia
2022-09-08 15:23:13 +08:00
commit 96a49d1bd6
26 changed files with 1597 additions and 0 deletions

57
app/tools/Aes.php Normal file
View File

@@ -0,0 +1,57 @@
<?php
// +------------------------------------------------+
// |http://www.vsyo.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 林义满 <steven.lin> |
// +------------------------------------------------+
namespace app\tools;
class Aes
{
/**
*
* @param string $string 需要加密的字符串
* @param string $key 密钥
* @return string
*/
/*
public static function encrypt($string, $key)
{
$data = openssl_encrypt($string, 'AES-256-ECB', $key, OPENSSL_RAW_DATA, null);
return base64_encode($data);
}
*/
/**
* @param string $string 需要解密的字符串
* @param string $key 密钥
* @return string
*/
/*
public static function decrypt($string, $key)
{
$string = base64_decode($string);
$data = openssl_decrypt($string, 'AES-256-ECB', $key, OPENSSL_RAW_DATA, null);
return $data;
}
*/
/**
* aes加密
* AES加密(PHP+FLUTTER)
*/
public static function encrypt($string ,$key)
{
return openssl_encrypt($string,"AES-256-CBC",$key,0 ,"0000000000000000");
}
/**
* aes解密
*/
public static function decrypt($string ,$key)
{
return openssl_decrypt($string,"AES-256-CBC",$key,0,"0000000000000000");
}
}