Files
heping-api/app/tools/Aes.php
knowpia 96a49d1bd6
2022-09-08 15:23:13 +08:00

58 lines
1.5 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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");
}
}