newSecretKey method

Future<SecretKey> newSecretKey()

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

Future<SecretKey> newSecretKey() async {
  return SecretKeyData.random(
    length: secretKeyLength,
    random: random,
  );
}