1、AES用的是encrypt
static String aesKey = 'sxcbk2gFGcODQp0daccgAh==';
//AES加密
static String aesEncode(String content) {
try {
final key = Key.fromUtf8(base64Encode(aesKey.codeUnits));
final encrypter = Encrypter(AES(key, mode: AESMode.ecb));
final encrypted = encrypter.encrypt(content, iv: IV.fromLength(16));
return encrypted.base64;
} catch (err) {
print("aes encode error:$err");
return content;
}
}
//AES解密
static dynamic aesDecode(dynamic base64) {
try {
final key = Key.fromUtf8(base64Encode(aesKey.codeUnits));
final encrypter = Encrypter(AES(key, mode: AESMode.ecb));
return encrypter.decrypt64(base64, iv: IV.fromLength(16));
} catch (err) {
print("aes decode error:$err");
return base64;
}
}
2、SHA-1使用的是crypto
String sign = sha1.convert(utf8.encode(str)).toString();