decrypt method

  1. @override
Uint8List decrypt(
  1. Encrypted encrypted, {
  2. IV? iv,
  3. Uint8List? associatedData,
})
override

Decrypt encrypted value.

Implementation

@override
Uint8List decrypt(Encrypted encrypted, {IV? iv, Uint8List? associatedData}) {
  if (mode != AESMode.ecb && iv == null) {
    throw StateError('IV is required.');
  }

  if (_streamCipher != null) {
    _streamCipher!
      ..reset()
      ..init(false, _buildParams(iv, associatedData: associatedData));

    return _streamCipher!.process(encrypted.bytes);
  }

  _cipher
    ..reset()
    ..init(false, _buildParams(iv, associatedData: associatedData));

  if (padding != null) {
    return _cipher.process(encrypted.bytes);
  }

  return _processBlocks(encrypted.bytes);
}