secure_random 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 50

secure_random #

pub package Build Status

Secure random generator.

This class use cryptographically secure source of random numbers.

Install #

Add this to your package's pubspec.yaml file:

dependencies:
  secure_random: ^1.0.0

Then install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Usage #

import 'package:secure_random/secure_random.dart';
    
var secureRandom = SecureRandom();
String s = secureRandom.nextString(length: 10);     // e.g. b4nc1evnip

You can also specific charset you want to use for random string.

import 'package:secure_random/secure_random.dart';

void main() {
  var secureRandom = SecureRandom();

  print(secureRandom.nextString(length: 10)); // e.g. 9FCjKnM4OW

  print(secureRandom.nextString(
      length: 10, charset: '0123456789')); // e.g. d8b08cbea6

  print(secureRandom.nextString(
      length: 10, charset: 'abcdefghijklmnopqrstuvwxyz')); // e.g. iqixgbjgfx

  print(secureRandom.nextString(
      length: 10, charset: '0123456789abcdef')); // e.g. d8b08cbea6

  print(secureRandom.nextString(
      length: 10,
      charset:
          'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')); // e.g. EUfpfiFEfv

  print(secureRandom.nextString(
      length: 10,
      charset:
          'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~!@#\$%^&*()_+`')); // e.g. sUkf1(xM3Z
}

Test #

Run test:

pub run test

License #

MIT. see LICENSE.

[1.0.1] - 2019-06-26

  • Update package description.

[1.0.0] - 2019-06-20

  • Add charset in nextString().

[0.9.0] - 2019-06-20

  • Initial release.

example/main.dart

import 'package:secure_random/secure_random.dart';

void main() {
  var secureRandom = SecureRandom();

  print(secureRandom.nextString(length: 10)); // e.g. 9FCjKnM4OW

  print(secureRandom.nextString(
      length: 10, charset: '0123456789')); // e.g. d8b08cbea6

  print(secureRandom.nextString(
      length: 10, charset: 'abcdefghijklmnopqrstuvwxyz')); // e.g. iqixgbjgfx

  print(secureRandom.nextString(
      length: 10, charset: '0123456789abcdef')); // e.g. d8b08cbea6

  print(secureRandom.nextString(
      length: 10,
      charset:
          'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')); // e.g. EUfpfiFEfv

  print(secureRandom.nextString(
      length: 10,
      charset:
          'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~!@#\$%^&*()_+`')); // e.g. sUkf1(xM3Z
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  secure_random: ^1.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:secure_random/secure_random.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Oct 11, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:secure_random/secure_random.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
Dev dependencies
test ^1.3.0