generateNonce function

String generateNonce([
  1. int length = 32
])

Generates a cryptographically secure random nonce, to be included in a credential request.

Implementation

String generateNonce([int length = 32]) {
  const charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._';
  final random = Random.secure();
  return List.generate(length, (_) => charset[random.nextInt(charset.length)]).join();
}