createCipher method

BlockCipher createCipher(
  1. Uint8List key,
  2. Uint8List iv, {
  3. required bool forEncryption,
})

Implementation

BlockCipher createCipher(
  Uint8List key,
  Uint8List iv, {
  required bool forEncryption,
}) {
  if (key.length != keySize) {
    throw ArgumentError.value(key, 'key', 'Key must be $keySize bytes long');
  }

  if (iv.length != ivSize) {
    throw ArgumentError.value(iv, 'iv', 'IV must be $ivSize bytes long');
  }

  final cipher = cipherFactory();
  cipher.init(forEncryption, ParametersWithIV(KeyParameter(key), iv));
  return cipher;
}