Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rndm

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rndm - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

28

index.js
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
var length = chars.length
var assert = require('assert')
module.exports = function rndm(len) {
var salt = ''
for (var i = 0; i < len; i++)
salt += chars[Math.floor(length * Math.random())]
return salt
var base62 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
var base36 = 'abcdefghijklmnopqrstuvwxyz0123456789'
var base10 = '0123456789'
exports = module.exports = create(base62)
exports.base62 = exports
exports.base36 = create(base36)
exports.base10 = create(base10)
exports.create = create
function create(chars) {
assert(typeof chars === 'string')
var length = Buffer.byteLength(chars)
return function rndm(len) {
assert(typeof len === 'number' && len >= 0)
var salt = ''
for (var i = 0; i < len; i++) salt += chars[Math.floor(length * Math.random())]
return salt
}
}
{
"name": "rndm",
"description": "random string generator",
"version": "1.0.0",
"version": "1.1.0",
"author": {

@@ -12,3 +12,22 @@ "name": "Jonathan Ong",

"license": "MIT",
"repository": "jonathanong/rndm"
"devDependencies": {
"mocha": "2",
"istanbul": "0"
},
"repository": "crypto-utils/rndm",
"scripts": {
"test": "mocha",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"
},
"keywords": [
"random",
"number",
"generator",
"uid",
"id"
],
"files": [
"index.js"
]
}

@@ -12,5 +12,17 @@

```js
import rndm from 'rndm@1'
// base62 by default
var rndm = require('rndm')
var salt = rndm(16)
```
### var salt = rndm(length)
### var salt = rndm.base62(length)
### var salt = rndm.base36(length)
### var salt = rndm.base10(length)
### var random = rndm.create(characters)
Create a new random generator with custom characters.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc