uuid_enhanced 3.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 89

Build Status codecov pub package

dart-uuid #

Version 3.0.0 has breaking API changes

Simple, fast generation of RFC4122 UUIDs.

Features:

  • Generate RFC4122 version 1, version 4, or version 5 UUIDs
  • Runs in web, server, and flutter
  • Cryptographically strong random number generation on all platforms
    • Defaults to non-crypto generator, see UuidUtil for cryptoRNG
  • API

Getting Started #

Instructions #

  1. Open a command line and cd to your projects root folder
  2. In your pubspec, add an entry for dart-uuid to your dependencies (example below)
  3. pub install
  4. If you wish to run tests, go into packages/dart-uuid/ and run 'dart test/uuid_test.dart'

Pubspec #

pub.dartlang.org: (you can use 'any' instead of a version if you just want the latest always)

dependencies:
  uuid_enhanced: ^3.0.0
import 'package:uuid_enhanced/uuid_enhanced.dart';

Then create some ids ...

// Generate a v1 (time-based) id
Uuid.fromTime(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'

// Generate a v4 (random) id
Uuid.randomUuid(); // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1'

// Generate a v4 (crypto-random) id
Uuid.randomUuid(random: UuidUtil.cryptoRNG());
// -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1'

// Generate a v5 (namespace-name-sha1-based) id
Uuid.fromName('www.google.com', namespace: Uuid.NAMESPACE_URL);
// -> 'c74a196f-f19d-5ea9-bffd-a2742432fc9c'

See more API

Testing #

In dartvm

dart test\uuid_test.dart

Benchmarking #

Its pretty quick, but no official benchmarking.

Release notes #

See CHANGELOG

v3.0.2

  • refactor toString method

v3.0.1

  • use factory rather than static method to create new Uuid

v3.0.0

  • Use Uint8List instead of List<int> for performance
  • All options are now named arguments instead of a map
  • Uuid is a type now (subtype of Uint8List)
  • No more singleton, all creating methods are not static ones
  • Proper implementation of == and hashCode
  • v1 renamed to fromTime, v4 renamed to emptyUuid, v5 renamed to fromName, parse renamed to fromString, unparse changed to instance method toString
  • New APIs isFromTime, millisecondsSinceEpoch, clockSequence

v2.0.1

  • Strong mode on dartanalyze

v2.0.0

  • Fixup the API to split out Buffer and Non-buffer usages.
  • Switch to build in Random.secure() and remove custom AES implementation.
  • Less dependencies.
  • Docs
  • Cleanup

v1.0.3

  • Fix SDK constraints to allow Dart 2.0 stable.

v1.0.2

  • Fix constants breaking in Dart 1.x, need to be backwards compatible.

v1.0.1

  • Fix constants to match Dart 2.0 spec

v1.0.0

  • Cleanup and prep for dart 2.0
  • Has been stable for a long time, upgrading to 1.0 version

v0.5.3

  • Merged pull request to support crypto 2.0.0
  • Support convert 2.0.0

v0.5.2

  • Merged pull request to upgrade crypto library to 1.0.0.

v0.5.1

  • Merged pull request for various updates and cleanup.

v0.5.0

  • Reverted back to custom AES implementation. Moved RNG methods to UuidUtil (import 'package:uuid/uuid_util.dart')
  • Fixed a potential bug with custom RNG method passing and added more ways to pass in custom RNG functions.
  • Cleaned up and refactored some stuff. Using only v1 is only 67kb of js, Using only v4 is 97kb. Using crypt v4 is 118kb. Using both v1 and non-crypto v4 is 126kb.
  • Default RNG for v4 is now the mathRNG function. If you wish to use cryptoRNG, import UuidUtil and pass in cryptoRNG.
  • Updated README.md with more examples and usages.
  • Updated Tests.

v0.4.1

  • Changed initCipher location so that if you ever only use v1 UUIDs, you will get a very small Dart2JS output compared to v4 or v5 that do load it.

v0.4.0

  • Use Cipher base.dart, as I don't need entropy generators, and this allows me to merge client/server together again and fix many issues this caused.

v0.3.2

  • Fix import/library bug.

v0.3.1

  • Update pubspec to allow installation of the latest Cipher 0.7.

v0.3.0

  • Updated to latest Cipher at 0.6.0. This created a breaking change in the imports. Please make sure you update your code.
  • Fixed problem when creating v4 UUIDs too fast, it would create duplicate UUIDs.

v0.2.2

  • Pegging cipher to 0.4.0 temporarily for browser support

v0.2.1

  • Using new version of cipher.

v0.2.0

  • Dart 1.0 Readiness
  • Switched from custom AES to cipher package AES.

v0.1.6

  • Adjusting usage of constants.
  • Fixing tests.

v0.1.5

  • Stupid typo on import.

v0.1.4

  • Fixing Crypto package move.

v0.1.3

  • Fixing language changes.

v0.1.2

  • Fix change of charCodes to codeUnits

v0.1.1

  • Fixing syntax for upcoming breaking changes.

v0.1.0

  • Cleanup, changes, and prep for M3.

v0.0.9

  • Minor fix with a const RegExp
  • Made sure everything builds on latest dart.
  • Fixed pubspec to now import unittest from pub instead of sdk.

v0.0.8

  • Changed to the new optional paramater syntaxes and usages.
  • Adjusted tests for the new function call style due to parameter change.
  • Fixed Import/Source/Library statements to the new format.

v0.0.7

  • Made changes requested by the Google team to get my package up on pub.dartlang.org

v0.0.6

  • Fixed up some code to make it possibly faster and using better Dart practices.
  • Cleaned up some documentation.

v0.0.5

  • Added Initial AES for Dart (untested if it actually works/matches other AES encryptors)
  • Use AES cipher to create crypto strong bytes.

v0.0.4

  • Issue wasn't Math.Random() but a bad reseed by me.
  • Cleaned up for new Pub layout.

v0.0.3

  • Added UUIDv5
  • Fixed UUIDv4 bugs
  • Added more unit tests
  • Found bug in dart's Math.Random(), reported, waiting for fix to fix my code.

v0.0.2

  • Initial tests
  • Fixed some parser bugs.

v0.0.1

  • Initial Release
  • No tests

example/example.dart

import 'package:uuid_enhanced/uuid.dart';
import 'package:uuid_enhanced/uuid_util.dart';

void main() {
  // Generate a v1 (time-based) UUID
  Uuid.fromTime(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'

  // Generate a v4 (random) UUID
  Uuid.randomUuid(); // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1'

  // Generate a v4 (crypto-random) UUID
  Uuid.randomUuid(random: UuidUtil.cryptoRNG());
  // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1'

  // Generate a v5 (namespace-name-sha1-based) UUID
  Uuid.fromName('www.google.com', namespace: Uuid.NAMESPACE_URL);
  // -> 'c74a196f-f19d-5ea9-bffd-a2742432fc9c'

  // Generate all 0s UUID
  Uuid.empty();
  // -> '00000000-0000-0000-0000-000000000000'
}

Use this package as a library

1. Depend on it

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


dependencies:
  uuid_enhanced: ^3.0.2

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:uuid_enhanced/uuid.dart';
import 'package:uuid_enhanced/uuid_util.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
78
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]
89
Learn more about scoring.

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

  • Dart: 2.6.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
collection ^1.14.11 1.14.12
convert >=2.0.0 <3.0.0 2.1.1
crypto >=2.0.0 <3.0.0 2.1.3
Transitive dependencies
charcode 1.1.2
typed_data 1.1.6
Dev dependencies
perfectionist ^2.0.0
test any