Search packages, repositories and app categories

Package detailsv1.2.0

nonce

Nonce contains a static generator that generates random alphanumeric strings, and can be constructed as an object containing a generated string.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
61.3K
Likes
12
Pub points
150

Install package

flutter pub add nonce

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The nonce package provides a simple static generator for creating random alphanumeric strings, useful for generating unique identifiers in security-sensitive contexts. It can be used either as a static utility or instantiated as an object holding a generated nonce. Designed with testing, cryptography, and permission systems in mind, it ensures unpredictability and uniqueness. The package is cross-platform, supporting Android, iOS, Web, macOS, Windows, and Linux, making it suitable for diverse application environments.

Use cases

  • Generating unique tokens for authentication
  • Creating test data with guaranteed uniqueness
  • Supporting cryptographic operations requiring nonces
  • Preventing replay attacks in network requests
  • Securing session management

Key features

  • Static generator for random alphanumeric strings
  • Object-based nonce instantiation
  • Cross-platform compatibility
  • Simple API for quick integration
  • Designed for security and testing use cases

Suitable for

  • Developers working on secure applications
  • Test engineers needing unique identifiers
  • Projects involving authentication or encryption
  • Applications requiring anti-replay protection
  • Flutter apps targeting multiple platforms

Considerations

  • Not intended for high-entropy cryptographic key generation
  • Ensure proper seeding if deterministic behavior is needed
  • Verify usage context aligns with security requirements
  • Avoid reuse of generated nonces in sensitive scenarios
  • Depends on Dart's random number generator, which may not be cryptographically strong in all environments

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

nonce

pub package

[Nonce] contains a static generator that generates random alphanumeric strings, and can be constructed as an object containing a generated string.

Usage

import 'package:nonce/nonce.dart';

Generator

The static method [generate] can be used to generate random alphanumeric strings.

[generate] has 2 optional parameters, [length] which defines how many characters to generate, and [random] which allows you provide a [Random] to use to generate the characters.

// Generate a string 32 characters long.
print(Nonce.generate()); // Osp54up7WU6P3U97Jz92p9j892n9LP7z

// Generate a string 64 characters long.
print(Nonce.generate(64)); // LDwpr1H74qm894jbd15Lj63wF5RUL07r4L9XOY7zVMz7fLbBCXa68Y6oPw0N9XgV

// Generate a nonce using a secure [Random].
print(Nonce.generate(32, Random.secure()));

generate() does not rely on Base64 encoding, instead it generates ASCII character codes directly.

Constructors

[Nonce]'s default constructor constructs a [Nonce] of the specified length; 32 characters by default.

Nonce();
Nonce(64);
unique

[Nonce]'s [unique] constructor references a global set of every nonce generated by it, and ensures that every nonce returned by it is unique.

Nonce.unique();
Nonce.unique(64);
secure

[Nonce]'s [secure] constructor generates a unique nonce using a secure [Random].

Nonce.secure();
Nonce.secure(64);
key

The [key] constructor is shorthand to generate a [unique] nonce 16 characters in length.

Nonce.key(); // Osp54up7WU6P3U97

Categories

Source repository

Projects using this package

No data available yet.