https://github.com/magic/cryptography
please note that this library is not in use in any of my other libraries (yet). consider it to be experimental at best.
https://github.com/magic/cryptography
Last synced: over 1 year ago
JSON representation
please note that this library is not in use in any of my other libraries (yet). consider it to be experimental at best.
- Host: GitHub
- URL: https://github.com/magic/cryptography
- Owner: magic
- Created: 2018-04-07T02:48:35.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-02-11T15:34:21.000Z (over 3 years ago)
- Last Synced: 2025-01-23T05:27:12.152Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 477 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## @magic/cryptography
magic cryptography utilities
not in use anywhere. do not use.
[![NPM version][npm-image]][npm-url]
[![Linux Build Status][travis-image]][travis-url]
[![Windows Build Status][appveyor-image]][appveyor-url]
[![Coverage Status][coveralls-image]][coveralls-url]
[![Greenkeeper badge][greenkeeper-image]][greenkeeper-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[npm-image]: https://img.shields.io/npm/v/@magic/cryptography.svg
[npm-url]: https://www.npmjs.com/package/@magic/cryptography
[travis-image]: https://api.travis-ci.org/magic/cryptography.svg?branch=master
[travis-url]: https://travis-ci.org/magic/cryptography
[appveyor-image]: https://img.shields.io/appveyor/ci/magic/cryptography/master.svg
[appveyor-url]: https://ci.appveyor.com/project/magic/cryptography/branch/master
[coveralls-image]: https://coveralls.io/repos/github/magic/cryptography/badge.svg
[coveralls-url]: https://coveralls.io/github/magic/cryptography
[greenkeeper-image]: https://badges.greenkeeper.io/magic/cryptography.svg
[greenkeeper-url]: https://badges.greenkeeper.io/magic/cryptography.svg
[snyk-image]: https://snyk.io/test/github/magic/cryptography/badge.svg
[snyk-url]: https://snyk.io/test/github/magic/cryptography
#### functions:
##### hash
##### jwt
Provides jwts using [jsonwebtoken](https://npmjs.com/package/jsonwebtoken)
##### random
Get random values
```javascript
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](https://npmjs.com/package/uuid) package
```javascript
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
```javascript
import { word } from '@magic/cryptography'
const generateWord = async () => {
const randomWord = await word()
return randomWord
}
generateWord()
```
##### words
Get multiple random words from the wordlist
```javascript
const generateWords = async () => {
const randomWords = await words(10)
return randomWords
}
generateWords()
```
##### wordlist
List with ~7000 words.
#### changelog
##### 0.0.1 - UNRELEASED
first release