{"_id":"random-number-csprng","_rev":"6-dd9654f2f77cc739ac843b32151f4e52","name":"random-number-csprng","description":"A cryptographically secure generator for random numbers in a range.","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.1":{"name":"random-number-csprng","version":"1.0.1","description":"A cryptographically secure generator for random numbers in a range.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/joepie91/node-random-number-csprng.git"},"keywords":["csprng","random","number","crypto"],"author":{"name":"Sven Slootweg"},"license":"WTFPL","dependencies":{"bluebird":"^3.3.3","create-error":"^0.3.1"},"devDependencies":{"babel-preset-es2015":"^6.6.0","gulp":"^3.9.1","gulp-babel":"^6.1.2","gulp-cached":"^1.1.0","gulp-plumber":"^1.1.0","gulp-remember":"^0.3.0","gulp-util":"^3.0.7"},"gitHead":"aabdb1fc5f3ac61573c2b63b93bd8c6f82804754","bugs":{"url":"https://github.com/joepie91/node-random-number-csprng/issues"},"homepage":"https://github.com/joepie91/node-random-number-csprng#readme","_id":"random-number-csprng@1.0.1","_shasum":"4f2d53b477bc4adecfdcc4656ce7a0921c09624d","_from":".","_npmVersion":"3.5.0","_nodeVersion":"4.2.1","_npmUser":{"name":"joepie91","email":"admin@cryto.net"},"dist":{"shasum":"4f2d53b477bc4adecfdcc4656ce7a0921c09624d","tarball":"https://registry.npmjs.org/random-number-csprng/-/random-number-csprng-1.0.1.tgz","integrity":"sha512-srUqpjR8nWG+UKLRLDKi5+4tkZMl0Z3VUGW1N56sezAcKj66sFSeXM3KHB8bfpBBCdS7AA3M1R+CRV9gYcTlbg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHJDZ246e41eNibU7pSWUXpaFH7EIxoiDCV4qw+54I+zAiEAl1UO2VwnQNBAgi3cnAE9EHYw1plfKxczJvQM15VNHq4="}]},"maintainers":[{"name":"joepie91","email":"admin@cryto.net"}],"_npmOperationalInternal":{"host":"packages-13-west.internal.npmjs.com","tmp":"tmp/random-number-csprng-1.0.1.tgz_1457470272661_0.6898321872577071"}},"1.0.2":{"name":"random-number-csprng","version":"1.0.2","description":"A cryptographically secure generator for random numbers in a range.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/joepie91/node-random-number-csprng.git"},"keywords":["csprng","random","number","crypto"],"author":{"name":"Sven Slootweg"},"license":"WTFPL","dependencies":{"bluebird":"^3.3.3","create-error":"^0.3.1"},"devDependencies":{"babel-preset-es2015":"^6.6.0","gulp":"^3.9.1","gulp-babel":"^6.1.2","gulp-cached":"^1.1.0","gulp-plumber":"^1.1.0","gulp-remember":"^0.3.0","gulp-util":"^3.0.7"},"gitHead":"48c849893aff1d09550a6c597cffb51c3df0c9c1","bugs":{"url":"https://github.com/joepie91/node-random-number-csprng/issues"},"homepage":"https://github.com/joepie91/node-random-number-csprng#readme","_id":"random-number-csprng@1.0.2","_shasum":"fcd120e62dffc2c07674c7c3fe01e16b25f73a26","_from":".","_npmVersion":"3.5.0","_nodeVersion":"4.2.1","_npmUser":{"name":"joepie91","email":"admin@cryto.net"},"dist":{"shasum":"fcd120e62dffc2c07674c7c3fe01e16b25f73a26","tarball":"https://registry.npmjs.org/random-number-csprng/-/random-number-csprng-1.0.2.tgz","integrity":"sha512-Gb7ZsEXfz6d9xAMCUg2tD0ouRZMOZRRvLsRoUyPlVS4/pNwO31IA88yAx6AEYXon/LzogWJdsCRwFQaFlQTaHw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCBTB5HvhMg/E2NliKIECHl+6DGuD3vw0uL5SckZZznIQIhAMfX8bpEkZSF9vTP26P+qHPYpoRQNnEZ+f6rcmq/tYdU"}]},"maintainers":[{"name":"joepie91","email":"admin@cryto.net"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/random-number-csprng-1.0.2.tgz_1457475051475_0.4802822768688202"}}},"readme":"# random-number-csprng\n\nA CommonJS module for generating cryptographically secure pseudo-random numbers.\n\nWorks in Node.js, and should work in the browser as well, using Webpack or Browserify.\n\nThis module is based on code [originally written](https://gist.github.com/sarciszewski/88a7ed143204d17c3e42) by [Scott Arciszewski](https://github.com/sarciszewski), released under the WTFPL / CC0 / ZAP.\n\n## License\n\n[WTFPL](http://www.wtfpl.net/txt/copying/) or [CC0](https://creativecommons.org/publicdomain/zero/1.0/), whichever you prefer. A donation and/or attribution are appreciated, but not required.\n\n## Donate\n\nMy income consists largely of donations for my projects. If this module is useful to you, consider [making a donation](http://cryto.net/~joepie91/donate.html)!\n\nYou can donate using Bitcoin, PayPal, Flattr, cash-in-mail, SEPA transfers, and pretty much anything else.\n\n## Contributing\n\nPull requests welcome. Please make sure your modifications are in line with the overall code style, and ensure that you're editing the files in `src/`, not those in `lib/`.\n\nBuild tool of choice is `gulp`; simply run `gulp` while developing, and it will watch for changes.\n\nBe aware that by making a pull request, you agree to release your modifications under the licenses stated above.\n\n## Usage\n\nThis module will return the result asynchronously - this is necessary to avoid blocking your entire application while generating a number.\n\nAn example:\n\n```javascript\nvar Promise = require(\"bluebird\");\nvar randomNumber = require(\"random-number-csprng\");\n\nPromise.try(function() {\n\treturn randomNumber(10, 30);\n}).then(function(number) {\n\tconsole.log(\"Your random number:\", number);\n}).catch({code: \"RandomGenerationError\"}, function(err) {\n\tconsole.log(\"Something went wrong!\");\n});\n```\n\n## API\n\n### randomNumber(minimum, maximum, [cb])\n\nReturns a Promise that resolves to a random number within the specified range.\n\nNote that the range is __inclusive__, and both numbers __must be integer values__. It is not possible to securely generate a random value for floating point numbers, so if you are working with fractional numbers (eg. `1.24`), you will have to decide on a fixed 'precision' and turn them into integer values (eg. `124`).\n\n* __minimum__: The lowest possible value in the range.\n* __maximum__: The highest possible value in the range. Inclusive.\n\nOptionally also accepts a nodeback as `cb`, but seriously, you should be using [Promises](https://gist.github.com/joepie91/791640557e3e5fd80861).\n\n### randomNumber.RandomGenerationError\n\nAny errors that occur during the random number generation process will be of this type. The error object will also have a `code` property, set to the string `\"RandomGenerationError\"`.\n\nThe error message will provide more information, but this kind of error will generally mean that the arguments you've specified are somehow invalid.\n\n## Changelog\n\n* __1.0.2__ (March 8, 2016): __*Security release!*__ Patched handling of large numbers; input values are now checked for `MIN_SAFE_INTEGER` and `MAX_SAFE_INTEGER`, and the correct bitwise operator is used (`>>>` rather than `>>`).\n* __1.0.1__ (March 8, 2016): Unimportant file cleanup.\n* __1.0.0__ (March 8, 2016): Initial release.","maintainers":[{"name":"joepie91","email":"admin@cryto.net"}],"time":{"modified":"2022-06-25T11:36:52.121Z","created":"2016-03-08T20:51:17.671Z","1.0.1":"2016-03-08T20:51:17.671Z","1.0.2":"2016-03-08T22:10:55.907Z"},"homepage":"https://github.com/joepie91/node-random-number-csprng#readme","keywords":["csprng","random","number","crypto"],"repository":{"type":"git","url":"git://github.com/joepie91/node-random-number-csprng.git"},"author":{"name":"Sven Slootweg"},"bugs":{"url":"https://github.com/joepie91/node-random-number-csprng/issues"},"license":"WTFPL","readmeFilename":"README.md","users":{"igorv":true,"qddegtya":true}}