decrypt static method
Implementation
static String? decrypt(
{String? secretkey = _sharedkey,
String? vector = _sharedkey,
String? text}) {
if (text == null) return null;
String? decrypted;
Uint8List encryptedText = base64Decode(text);
Uint8List key = Uint8List.fromList(utf8.encode(secretkey!));
Uint8List iv = Uint8List.fromList(utf8.encode(vector!));
final CBCBlockCipher cbcCipher = CBCBlockCipher(AESEngine());
final ParametersWithIV<KeyParameter> ivParams =
ParametersWithIV<KeyParameter>(KeyParameter(key), iv);
final PaddedBlockCipherParameters<ParametersWithIV<KeyParameter>,
CipherParameters?> paddingParams =
PaddedBlockCipherParameters<ParametersWithIV<KeyParameter>,
CipherParameters?>(ivParams, null);
final PaddedBlockCipherImpl cipher =
PaddedBlockCipherImpl(PKCS7Padding(), cbcCipher);
cipher.init(false, paddingParams);
try {
Uint8List clearText = cipher.process(encryptedText);
decrypted = String.fromCharCodes(clearText);
} catch (e) {
Log().exception(e);
}
return decrypted;
}