夺
This commit is contained in:
57
app/tools/Aes.php
Normal file
57
app/tools/Aes.php
Normal 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");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user