magic cryptography utilities
not in use anywhere. do not use.
Provides jwts using jsonwebtoken
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).
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)
Get a single random word from the wordlist
import { word } from '@magic/cryptography'
const generateWord = async () => {
const randomWord = await word()
return randomWord
}
generateWord()
Get multiple random words from the wordlist
const generateWords = async () => {
const randomWords = await words(10)
return randomWords
}
generateWords()
List with ~7000 words.
first release