init method

  1. @override
void init(
  1. bool forEncryption,
  2. CipherParameters? params
)
override

Init the cipher with its initialization params. The type of CipherParameters depends on the algorithm being used (see the documentation of each implementation to find out more).

Use the argument forEncryption to tell the cipher if you want to encrypt or decrypt data.

Implementation

@override
void init(bool forEncryption, CipherParameters? params) {
  if (params is KeyParameter) {
    _forEncryption = forEncryption;
    _workingKey = params.key;
    final keyBits = _workingKey.length * 8;
    if (!(keyBits == 128 || keyBits == 192 || keyBits == 256)) {
      throw ArgumentError('Key length not 128/192/256 bits.');
    }
    _setupKey(_workingKey);
  } else {
    throw ArgumentError(
      'Invalid parameter passed to $algorithmName init - ${params.runtimeType}',
    );
  }
}