generateNonce function

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

Generate a cryptographically secure random nonce

Implementation

String generateNonce({int length = 32}) {
  final random = Random.secure();

  return Iterable.generate(
    length,
    (_) => _chars[random.nextInt(_chars.length)],
  ).join();
}