newSecretKey method

  1. @override
Future<SecretKey> newSecretKey()
inherited

Generates a new SecretKey.

It will have the correct length (secretKeyLength).

The source of random bytes is Random.secure (a cryptographically secure random number generator) unless a custom random number generator was specified when you constructed the cipher (or your Cryptography instance).

Implementation

@override
Future<SecretKey> newSecretKey() {
  final bytes = Uint8List(secretKeyLength);
  fillBytesWithSecureRandom(bytes, random: random);
  return Future<_DartAesSecretKeyData>.value(_DartAesSecretKeyData(
    bytes,
    overwriteWhenDestroyed: true,
  ));
}