sodium-uuid
Generate v4 UUIDs using libsodium's RNG
Last updated 5 months ago by emilbayes .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install sodium-uuid 
SYNC missed versions from official npm registry.

sodium-uuid

Build Status

Generate v4 UUIDs using libsodium's RNG

Usage

var uuid = require('sodium-uuid')

uuid() // => Buffer
uuid(Buffer.allocUnsafe(uuid.BYTES)) // => allocUnsafe'ed 16 byte Buffer

API

var buf = uuid([buf])

Optional argument buf must be a Buffer of at least 128 bits (16 bytes). This module will fill the first 16 bytes with random bits but set the appropriate bits to be recognised as a UUID v4. This leaves 122 bits of entropy. This method does not insert dashes in the formatting, but this can be done with the uuid.stringify method.

var str = uuid.stringify(buf)

Convert buf to string representation of UUID eg. 4a181507-72e2-45c7-a512-9d9601425b2d. Will only read the first 16 bytes of buf.

var buf = uuid.parse(str, [buf])

Convert str to Buffer representation of UUID, written to optional argument buf, which must be Buffer of at least length uuid.BYTES. Will be allocated if not given. Will fail if str is not a valid UUIDv4

var bool = uuid.isUUID(obj)

Check that obj is a valid UUIDv4. obj can be either a string or Buffer

uuid.BYTES

Constant defining the number of bytes buf must be able to contain.

Install

npm install sodium-uuid

License

ISC

Current Tags

  • 2.0.0                                ...           latest (5 months ago)

10 Versions

  • 2.0.0                                ...           5 months ago
  • 1.3.0                                ...           3 years ago
  • 1.2.2                                ...           3 years ago
  • 1.2.1                                ...           4 years ago
  • 1.2.0                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.3                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 2
This Month 6
Last Day 0
Last Week 4
Last Month 4
Dependencies (1)
Dev Dependencies (2)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |