generateSecureKey static method

String generateSecureKey({
  1. int length = 32,
})

Generates a secure random key.

The length parameter specifies the length of the key in bytes. Returns the key as a base64-encoded string.

Implementation

static String generateSecureKey({int length = 32}) {
  final key = Key.fromSecureRandom(length);
  return base64Encode(key.bytes);
}