登录调通
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
import 'package:encrypt/encrypt.dart';
|
||||
|
||||
class LoginUtil {
|
||||
// 定义密钥
|
||||
// 对于ECB模式,我们只需要Key,不需要IV (初始化向量)
|
||||
static final _keyString = '915eae87951a448c86c47796e44c1fcf';
|
||||
static final _key = Key.fromUtf8(_keyString);
|
||||
|
||||
// 【核心修改】创建使用 ECB 模式的加密器实例
|
||||
// 1. mode: AESMode.ecb -> 使用ECB模式,它不需要IV。
|
||||
// 2. padding: 'PKCS7' -> 在encrypt库中,PKCS5和PKCS7的填充方式是兼容的。
|
||||
static final _encrypter = Encrypter(AES(_key, mode: AESMode.ecb, padding: 'PKCS7'));
|
||||
|
||||
/// AES 加密方法
|
||||
@@ -16,10 +11,8 @@ class LoginUtil {
|
||||
if (plainText.isEmpty) {
|
||||
return '';
|
||||
}
|
||||
// 【核心修改】调用 encrypt 方法时不再需要传递 iv
|
||||
final encrypted = _encrypter.encrypt(plainText);
|
||||
|
||||
// 返回Base64编码的密文,这是网络传输的标准做法
|
||||
return encrypted.base64;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user