1.1.1 • Published 5 years ago

awesome-crypto v1.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Generates secure random numbers using crypto.randomBytes(). Numbers can be of any magnitude and in any base from 2 to 64.

This package is a full rework of my old package csprng-64 but now far better. I decided to release it as a completely separate package and deprecate the previous one as the entire code base was changed and I wasn't fond of the previous name either.

Install

Install with yarn:

$ yarn add awesome-crypto

Usage

Call the function passing the number of required bits, and the radix of the output.

const { crypto } = require('awesome-crypto'); // import { crypto } from 'awesome-crypto';

// Takes a bit length and base parameter
// base examples are base64 or base32
crypto(160, 64);

// You can also import the predefined Radix's so you can be sure you're using a supported radix
const { Radix } = require('awesome-crypto'); // import { Radix } from 'awesome-crypto'
crypto(160, Radix.base64);

Documentation

Constants

Functions

Radix : enum

Kind: global enum
Properties

NameType
16Radix.base16
32Radix.base32
58Radix.base58
64Radix.base64

DEFAULT_BITS : number

Kind: global constant

DEFAULT_RADIX : number

Kind: global constant

crypto(bits, radix) ⇒ string

Kind: global function
Returns: string - The cryptographic string

ParamTypeDefaultDescription
bitsnumberDEFAULT_BITSThe amount of bits to generate
radixRadixDEFAULT_RADIXThe radix to generate for

About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

License

Copyright © 2019, Favna. Released under the MIT License.

Buy me a donut

This project is open source and always will be, even if I don't get donations. That said, I know there are people out there that may still want to donate just to show their appreciation so this is for you guys. Thanks in advance!

I accept donations through PayPal, BitCoin, Ethereum and LiteCoin. You can use the buttons below to donate through your method of choice

Donate WithQRAddress
Donate with PayPal
1E643TNif2MTh75rugepmXuq35Tck4TnE5
0xF653F666903cd8739030D2721bF01095896F5D6E
LZHvBkaJqKJRa8N7Dyu41Jd1PDBAofCik6
1.1.1

5 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago