aesDecrypt function
Uint8List
aesDecrypt(
- dynamic cipherText,
- dynamic key
)
Implementation
Uint8List aesDecrypt(cipherText, key) {
if (!(cipherText is Uint8List) && !(cipherText is String)) {
throw "'cipherText' must be a string or Uint8List";
}
if (!(key is Uint8List) && !(key is String)) {
throw "'key' must be a string or Uint8List";
}
if (cipherText is String) {
if (isHex(cipherText)) {
cipherText = hexToUint8List(cipherText);
} else {
throw "'cipherText' must be an hexadecimal string";
}
}
if (key is String) {
if (isHex(key)) {
key = hexToUint8List(key);
} else {
throw "'key' must be an hexadecimal string";
}
}
// TODO
/*
Uint8List iv = cipherText.sublist(0, 12);
Uint8List tag = cipherText.sublist(12, 12 + 16);
Uint8List encrypted = cipherText.sublist(28, cipherText.length);
final gcm = GCMBlockCipher(AESFastEngine())
..init(false, AEADParameters(KeyParameter(key), 8 * 16, iv, tag));
final paddedPlainText = Uint8List(encrypted.length);
var offset = 0;
while (offset < encrypted.length) {
offset += gcm.processBlock(encrypted, offset, paddedPlainText, offset);
}
*/
return Uint8List(0);
}