initializeSync method

void initializeSync({
  1. required bool isEncrypting,
  2. required SecretKey secretKey,
  3. required List<int> nonce,
  4. List<int> aad = const [],
  5. int keyStreamIndex = 0,
})

Implementation

void initializeSync({
  required bool isEncrypting,
  required SecretKey secretKey,
  required List<int> nonce,
  List<int> aad = const [],
  int keyStreamIndex = 0,
}) {
  _isInitialized = false;
  _isEncrypting = isEncrypting;
  this.keyStreamIndex = keyStreamIndex;
  final secretKeyData = secretKey as SecretKeyData;
  final derivedSecretKey = deriveKeySync(
    secretKey: secretKeyData,
    nonce: nonce,
  );
  final derivedNonce = deriveNonce(
    secretKey: secretKeyData,
    nonce: nonce,
  );
  final macSink = cipher.macAlgorithm.toSync().newMacSinkSync(
        secretKeyData: secretKeyData,
        nonce: nonce,
        aad: aad,
      );
  _macSink = macSink;
  assert(!_isInitialized);
  _isInitialized = true;
  beforeData(
    secretKey: derivedSecretKey,
    nonce: derivedNonce,
    aad: aad,
  );
}