0.2.2 • Published 4 years ago

secure-id v0.2.2

Weekly downloads
10
License
MIT
Repository
github
Last release
4 years ago

secure-id

Secure id generator for Browsers, Node.js, and ReactNative written in TypeScript.

Features

  • Secure: Generates cryptographically secure random ids using window.crypto for Browsers, require('crypto') for Node.js, and react-native-get-random-values for ReactNative.
  • Fast: Much faster than uuid4.
  • Tiny: Only 612 bytes of gzipped, minified.

Compatible for es6+

Install

npm install secure-id

Usage

import {create} from 'secure-id

// function create(characters: string): (length: number) => string
const {generate, validate} = create('ab01')(6)

// id -> 'b110ba', 'a01aab', '0bba01' etc.
const id = generate()

// true
validate(id)
validate('aaaaaa')
validate('01ab00')

// false
validate('aaaaa') //invalid length
validate('aaaaad') //invalid characters
0.2.1

4 years ago

0.2.2

4 years ago

0.2.0

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago