https://github.com/mobylogix/node-random
Node Package to generate random string.
https://github.com/mobylogix/node-random
crypto mobylogix node
Last synced: 2 months ago
JSON representation
Node Package to generate random string.
- Host: GitHub
- URL: https://github.com/mobylogix/node-random
- Owner: mobylogix
- Created: 2018-01-11T15:57:23.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-11T15:58:54.000Z (over 7 years ago)
- Last Synced: 2025-01-19T18:47:31.701Z (4 months ago)
- Topics: crypto, mobylogix, node
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@mobylogix/node-random
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# random
```
npm i --save @mobylogix/node-random
``````javascript
import {Random} from '@mobylogix/node-random';let id = Random.id();
```The `random` package provides several functions for generating random
numbers. It uses a cryptographically strong pseudorandom number generator when
possible, but falls back to a weaker random number generator when
cryptographically strong randomness is not available (on older browsers or on
servers that don't have enough entropy to seed the cryptographically strong
generator).- `Random.id([n])` - Returns a unique identifier, such as `"Jjwjg6gouWLXhMGKW"`, that is
likely to be unique in the whole world. The optional argument `n`
specifies the length of the identifier in characters and defaults to 17.- `Random.secret([n])` - Returns a random string of printable characters with 6 bits of
entropy per character. The optional argument `n` specifies the length of
the secret string and defaults to 43 characters, or 256 bits of
entropy. Use `Random.secret` for security-critical secrets that are
intended for machine, rather than human, consumption.- `Random.fraction()` - Returns a number between 0 and 1, like `Math.random`.
- `Random.choice(arrayOrString)` - Returns a random element of the given array or string.
- `Random.hexString(n)` - Returns a random string of `n` hexadecimal digits.