{"id":16731427,"url":"https://github.com/skratchdot/random-seed","last_synced_at":"2025-04-09T16:19:54.857Z","repository":{"id":11433724,"uuid":"13888346","full_name":"skratchdot/random-seed","owner":"skratchdot","description":"GRC's UHE PRNG in node (Ultra-High Entropy Pseudo-Random Number Generator by Gibson Research Corporation)","archived":false,"fork":false,"pushed_at":"2016-09-19T17:58:54.000Z","size":21,"stargazers_count":94,"open_issues_count":1,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T16:19:50.892Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skratchdot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-GRC","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-26T18:08:00.000Z","updated_at":"2024-12-18T15:57:14.000Z","dependencies_parsed_at":"2022-09-19T05:40:49.069Z","dependency_job_id":null,"html_url":"https://github.com/skratchdot/random-seed","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skratchdot%2Frandom-seed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skratchdot%2Frandom-seed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skratchdot%2Frandom-seed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skratchdot%2Frandom-seed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skratchdot","download_url":"https://codeload.github.com/skratchdot/random-seed/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065281,"owners_count":21041872,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T23:37:08.024Z","updated_at":"2025-04-09T16:19:54.827Z","avatar_url":"https://github.com/skratchdot.png","language":"JavaScript","readme":"# random-seed\n\n[![NPM version](https://badge.fury.io/js/random-seed.svg)](http://badge.fury.io/js/random-seed)\n[![Build Status](https://travis-ci.org/skratchdot/random-seed.png?branch=master)](https://travis-ci.org/skratchdot/random-seed)\n[![Code Climate](https://codeclimate.com/github/skratchdot/random-seed.png)](https://codeclimate.com/github/skratchdot/random-seed)\n[![Coverage Status](https://coveralls.io/repos/skratchdot/random-seed/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/skratchdot/random-seed?branch=master)\n[![Dependency Status](https://david-dm.org/skratchdot/random-seed.svg)](https://david-dm.org/skratchdot/random-seed)\n[![devDependency Status](https://david-dm.org/skratchdot/random-seed/dev-status.svg)](https://david-dm.org/skratchdot/random-seed#info=devDependencies)\n\n[![NPM](https://nodei.co/npm/random-seed.png)](https://npmjs.org/package/random-seed)\n\n\n## Description\n\nGibson Research Corporation's Ultra-High Entropy Pseudo-Random Number Generator\nported to node.\n\nThe original library / project page is located here: https://www.grc.com/otg/uheprng.htm\n\nThe node project page is here: https://github.com/skratchdot/random-seed\n\nThere were a few modifications made to the original library to allow seeding, and to\npass jshint.\n\nI've also added the following helper methods:\n\n- random()\n- range(range)\n- floatBetween(min, max)\n- intBetween(min, max)\n\n\n## Getting Started\n\nInstall the module with: `npm install random-seed`\n\n```javascript\nvar rand = require('random-seed').create();\nvar n = rand(100); // generate a random number between 0 - 99\n```\n\n\n## Documentation\n\n### Create a random number generator\n\n```javascript\nvar gen = require('random-seed'); // create a generator\n\n// these generators produce different numbers\nvar rand1 = gen.create(); // method 1\nvar rand2 = new gen();    // method 2\nvar rand3 = gen();        // method 3\n\n// these generators will produce\n// the same sequence of numbers\nvar seed = 'My Secret String Value';\nvar rand4 = gen.create(seed);\nvar rand5 = new gen(seed);\nvar rand6 = gen(seed);\n```\n\n### Random Generator Methods\n\nOnce a random generator is created, you have the following methods available.\n\nI typically create a random generator like this:\n\n```javascript\nvar rand = require('random-seed').create();\n```\n\n#### rand(range)\n\nReturns a random integer between 0 (inclusive) and range (exclusive)\n\n#### rand.range(range)\n\nReturns a random integer between 0 (inclusive) and range (exclusive)\n\n#### rand.random()\n\nReturns a random float between 0 (inclusive) and 1 (exclusive)\n\nWorks the same as Math.random()\n\n#### rand.floatBetween(min, max)\n\nReturns a random float between min (inclusive) and max (exclusive)\n\n#### rand.intBetween(min, max)\n\nReturns a random integer between min (inclusive) and max (inclusive)\n\n#### rand.seed(seed)\n\nSame as calling rand.initState() followed by rand.hashString(seed). If seed is not\na string, then the seed value will be converted to a string. If you don't pass a\nseed argument, then the generator uses Math.random() as the seed.\n\n#### rand.string(count)\n\nReturns a pseudo-random string of 'count' printable characters\nranging from chr(33) to chr(126) inclusive.\n\n#### rand.cleanString(inStr)\n\nRemoves leading and trailing spaces and non-printing control characters,\nincluding any embedded carriage-return (CR) and line-feed (LF) characters,\nfrom any string it is handed.  This is also used by the 'hashstring' function (below)\nto help users always obtain the same EFFECTIVE uheprng seeding key.\n\n#### rand.hashString(inStr)\n\nHashes the provided character string after first removing any leading or trailing spaces\nand ignoring any embedded carriage returns (CR) or Line Feeds (LF).\n\n#### rand.addEntropy(/* accept zero or more arguments */)\n\nThis handy exported function is used to add entropy to our uheprng at any time.\n\n#### rand.initState()\n\nIf we want to provide a deterministic startup context for our PRNG,\nbut without directly setting the internal state variables, this allows\nus to initialize the mash hash and PRNG's internal state before providing\nsome hashing input.\n\n#### rand.done()\n\nWe use this (optional) exported function to signal the JavaScript interpreter\nthat we're finished using the internal \"Mash\" hash function so that it can free up the\nlocal \"instance variables\" it will have been maintaining.  It's not strictly\nnecessary, of course, but it's good JavaScript citizenship.\n\n\n## Examples\n\n### Default Usage: create 1 random number between 0 - 99\n```javascript\nvar rand = require('random-seed').create();\nvar n = rand(100); // generate a random number between 0 - 99\n```\n\n### Always create same sequence of random numbers\n```javascript\nvar rand = require('random-seed').create();\nrand.initState();\nvar n1 = rand(100); // n1 === 58\nvar n2 = rand(100); // n2 === 26\nrand.initState();   // re-init\nvar n3 = rand(100); // n3 === 58 \u0026\u0026 n3 === n1\n```\n\n### Create 2 random number generators\n```javascript\nvar rand1 = require('random-seed').create(),\n\trand2 = require('random-seed').create();\nconsole.log(rand1(100), rand2(100));\n```\n\n### Create 2 random number generators with the same seed\n```javascript\nvar seed = 'Hello World',\n\trand1 = require('random-seed').create(seed),\n\trand2 = require('random-seed').create(seed);\nconsole.log(rand1(100), rand2(100));\n```\n\n### Replace Math.random()\n```javascript\nvar math = require('random-seed').create();\nconsole.log(math.random());\n```\n\n\n## Release History\n\n#### v0.2.0 (Released June 1, 2014)\n\n- Adding the following helper methods:\n  - rand.random(min, max)\n  - rand.floatBetween(min, max)\n  - rand.intBetween(min, max)\n\n#### v0.1.0 (Released October 26, 2013)\n\n- Initial Release\n\n\n## License\n\nCopyright (c) 2013 skratchdot  \n\nDual Licensed under the MIT license and the original Public Domain License by GRC.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskratchdot%2Frandom-seed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskratchdot%2Frandom-seed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskratchdot%2Frandom-seed/lists"}