gpt4 book ai didi

encryption - flutter :错误:类型 'String'不是 'Encrypted'的类型 'encrypted'的子类型

转载 作者:行者123 更新时间:2023-12-03 03:25:36 25 4
gpt4 key购买 nike

我正在使用:encrypt: ^3.2.0我在 flutter 中使用 AES 加密,但是当我解密我的加密值时,它会给我这种类型的错误。

flutter: 错误: 类型 'String' 不是 'encrypted' 的 'Encrypted' 类型的子类型

Future<String> getEncryption(String text) async {
String enc = '';

final SharedPreferences strFamilyPass =
await SharedPreferences.getInstance();
strFamilyPass.getString('family');

final String keys = await getKEY();
final dynamic key = Key.fromUtf8(keys);
final dynamic iv = IV.fromLength(16);
final dynamic encrypter = Encrypter(AES(key));
final String salt = await getSalt();
enc = '$salt${encrypter.encrypt(text, iv: iv).base64}';
print('encryption $enc');
return enc;
}

Future<String> getDecryption(String text) async {
String dec = '';
final String keys = await getKEY();
final dynamic key = Key.fromUtf8(keys);
final dynamic iv = IV.fromLength(16);
final encrypter = Encrypter(AES(key));
final String salt = await getSalt();

dec = '$salt${encrypter.decrypt(text, iv: iv)}';// it give's me error right here
print('decy $dec');
return dec;
}

最佳答案

var source = 'flutter app';
final decrypted = encrypter.decrypt64(source, iv: iv);

关于encryption - flutter :错误:类型 'String'不是 'Encrypted'的类型 'encrypted'的子类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57882818/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com