diff options
Diffstat (limited to 'node_modules/rndm')
| -rw-r--r-- | node_modules/rndm/LICENSE | 22 | ||||
| -rw-r--r-- | node_modules/rndm/README.md | 27 | ||||
| -rw-r--r-- | node_modules/rndm/index.js | 25 | ||||
| -rw-r--r-- | node_modules/rndm/package.json | 99 |
4 files changed, 173 insertions, 0 deletions
diff --git a/node_modules/rndm/LICENSE b/node_modules/rndm/LICENSE new file mode 100644 index 0000000..a7ae8ee --- /dev/null +++ b/node_modules/rndm/LICENSE @@ -0,0 +1,22 @@ + +The MIT License (MIT) + +Copyright (c) 2014 Jonathan Ong me@jongleberry.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/rndm/README.md b/node_modules/rndm/README.md new file mode 100644 index 0000000..504b1fd --- /dev/null +++ b/node_modules/rndm/README.md @@ -0,0 +1,27 @@ + +# RNDM + +Random string generator. +Basically `Math.random().toString(36).slice(2)`, +but with both upper and lower case letters and arbitrary lengths. +Useful for creating fast, not cryptographically secure salts. + +## API + +```js +// 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. diff --git a/node_modules/rndm/index.js b/node_modules/rndm/index.js new file mode 100644 index 0000000..24b0ebb --- /dev/null +++ b/node_modules/rndm/index.js @@ -0,0 +1,25 @@ + +var assert = require('assert') + +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', 'the list of characters must be a string!') + var length = Buffer.byteLength(chars) + return function rndm(len) { + len = len || 10 + assert(typeof len === 'number' && len >= 0, 'the length of the random string must be a number!') + var salt = '' + for (var i = 0; i < len; i++) salt += chars[Math.floor(length * Math.random())] + return salt + } +} diff --git a/node_modules/rndm/package.json b/node_modules/rndm/package.json new file mode 100644 index 0000000..a53c74d --- /dev/null +++ b/node_modules/rndm/package.json @@ -0,0 +1,99 @@ +{ + "_args": [ + [ + "rndm@1.2.0", + "/home/humair/School/csc309/a4/solutions_repo/node_modules/csrf" + ] + ], + "_from": "rndm@1.2.0", + "_id": "rndm@1.2.0", + "_inCache": true, + "_installable": true, + "_location": "/rndm", + "_nodeVersion": "4.1.1", + "_npmUser": { + "email": "coderhaoxin@outlook.com", + "name": "coderhaoxin" + }, + "_npmVersion": "2.14.4", + "_phantomChildren": {}, + "_requested": { + "name": "rndm", + "raw": "rndm@1.2.0", + "rawSpec": "1.2.0", + "scope": null, + "spec": "1.2.0", + "type": "version" + }, + "_requiredBy": [ + "/csrf" + ], + "_resolved": "https://registry.npmjs.org/rndm/-/rndm-1.2.0.tgz", + "_shasum": "f33fe9cfb52bbfd520aa18323bc65db110a1b76c", + "_shrinkwrap": null, + "_spec": "rndm@1.2.0", + "_where": "/home/humair/School/csc309/a4/solutions_repo/node_modules/csrf", + "author": { + "email": "me@jongleberry.com", + "name": "Jonathan Ong", + "url": "http://jongleberry.com" + }, + "bugs": { + "url": "https://github.com/crypto-utils/rndm/issues" + }, + "dependencies": {}, + "description": "random string generator", + "devDependencies": { + "istanbul": "0", + "mocha": "2" + }, + "directories": {}, + "dist": { + "shasum": "f33fe9cfb52bbfd520aa18323bc65db110a1b76c", + "tarball": "https://registry.npmjs.org/rndm/-/rndm-1.2.0.tgz" + }, + "files": [ + "index.js" + ], + "gitHead": "9d566c844a4c83487f3b2621be5b6588d5a2b617", + "homepage": "https://github.com/crypto-utils/rndm#readme", + "keywords": [ + "generator", + "id", + "number", + "random", + "uid" + ], + "license": "MIT", + "maintainers": [ + { + "name": "coderhaoxin", + "email": "coderhaoxin@outlook.com" + }, + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "fishrock123", + "email": "fishrock123@rocketmail.com" + }, + { + "name": "jongleberry", + "email": "jonathanrichardong@gmail.com" + } + ], + "name": "rndm", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/crypto-utils/rndm.git" + }, + "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" + }, + "version": "1.2.0" +} |
