Skip to content

please note that this library is not in use in any of my other libraries (yet). consider it to be experimental at best.

Notifications You must be signed in to change notification settings

magic/cryptography

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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

About

please note that this library is not in use in any of my other libraries (yet). consider it to be experimental at best.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published