Skip to content

Latest commit

 

History

History
105 lines (73 loc) · 2.59 KB

README.md

File metadata and controls

105 lines (73 loc) · 2.59 KB

@magic/cryptography

magic cryptography utilities

not in use anywhere. do not use.

NPM version Linux Build Status Windows Build Status Coverage Status Greenkeeper badge Known Vulnerabilities

functions:

hash
jwt

Provides jwts using jsonwebtoken

random

Get random values

  import { random } from '@magic/cryptography'

  const randomValues = async () => {
    const num = await random.number({
      min: Number.MIN_SAFE_INTEGER,
      max: Number.MAX_SAFE_INTEGER,
    })

    const nums = await random.numbers(10)
    // get 10 random numbers. clamping not implemented yet.

    const bytes = await random.bytes(33)
    // get 33 random bytes (... a string).
uuid

Generate v4 and (namespaced) v5 uuids using the uuid package

import { uuid } from '@magic/cryptography'

const v4 = uuid.v4()

// uuid v5 namespaces
const { DNS, URL, OID, X500 } = uuid.v5

const namespaceUuid = uuid.addNS('name')
const v5 = uuid.v5(namespaceUuid || 'name', DNS)
word

Get a single random word from the wordlist

import { word } from '@magic/cryptography'

const generateWord = async () => {
  const randomWord = await word()
  return randomWord
}
generateWord()
words

Get multiple random words from the wordlist

const generateWords = async () => {
  const randomWords = await words(10)
  return randomWords
}
generateWords()
wordlist

List with ~7000 words.

changelog

0.0.1 - UNRELEASED

first release