{"id":16338954,"url":"https://github.com/phadej/rc4","last_synced_at":"2025-03-22T23:32:47.106Z","repository":{"id":15325049,"uuid":"18055204","full_name":"phadej/rc4","owner":"phadej","description":"RC4 random number generator","archived":false,"fork":false,"pushed_at":"2019-11-07T17:31:51.000Z","size":24,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T15:48:50.026Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phadej.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-24T07:46:06.000Z","updated_at":"2022-04-30T22:59:03.000Z","dependencies_parsed_at":"2022-08-26T07:10:41.082Z","dependency_job_id":null,"html_url":"https://github.com/phadej/rc4","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phadej%2Frc4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phadej%2Frc4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phadej%2Frc4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phadej%2Frc4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phadej","download_url":"https://codeload.github.com/phadej/rc4/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245036127,"owners_count":20550662,"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-10T23:53:09.093Z","updated_at":"2025-03-22T23:32:46.808Z","avatar_url":"https://github.com/phadej.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rc4\n\n[RC4](http://en.wikipedia.org/wiki/RC4) random number generator\n\n[![Build Status](https://secure.travis-ci.org/phadej/rc4.svg?branch=master)](http://travis-ci.org/phadej/rc4)\n[![NPM version](https://badge.fury.io/js/rc4.svg)](http://badge.fury.io/js/rc4)\n[![Dependency Status](https://gemnasium.com/phadej/rc4.svg)](https://gemnasium.com/phadej/rc4)\n[![Code Climate](https://img.shields.io/codeclimate/github/phadej/rc4.svg)](https://codeclimate.com/github/phadej/rc4)\n\n## Synopsis\n\n```js\nvar RC4 = require(\"rc4\");\n\nvar generator = new RC4(\"my seed\"); // string or array of integers\n// without the seed RNG is seeded with random data from Math.random\n\n// byte := integer ∈ [0, 255]\nconsole.log(generator.randomByte());\n\n// float := number ∈ [0, 1)\nconsole.log(generator.randomFloat());\n\n// save \u0026 load state\nvar state = generator.currentState();\nconsole.log(generator.randomFloat()); // 0.14815412228927016\ngenerator.setState(state);\nconsole.log(generator.randomFloat()); // 0.14815412228927016\n```\n\n## RC4small\n\nThere is also `RC4small` generator, with smaller internal state:\n\n```\nvar RC4small = require(\"rc4\").RC4small;\n\nvar generator = new RC4small(\"my seed\");\n\nvar stateString = generator.currentStateString(); // 18 character hexadecimal string\nconsole.log(generator.randomFloat());  // 0.9362740234937519\ngenerator.setStateString(stateString);\nconsole.log(generator.randomFloat()); // 0.9362740234937519\n```\n\n## API\n\nBoth `RC4` and `RC4small` have following random value generating methods:\n\n```\nrandomByte   : () ⇒ { x : ℕ | x ∈ [0, 255] }\nrandomUInt32 : () ⇒ { x : ℕ | x ∈ [0, 2^32-1] }\nrandomFloat  : () ⇒ { x : R | x ∈ [0, 1) }\nrandom       : (a : ℤ)        ⇒ { x : ℤ | x ∈ [0, a] }\nrandom       : (a : ℤ, b : ℤ) ⇒ { x : ℤ | x ∈ [a, b] }\n```\n\n## Changelog\n\n- **0.1.5** \u0026mdash; *2015-04-24* \u0026mdash; Better isInteger, random works with bigger ranges\n- **0.1.4** \u0026mdash; *2015-02-25* \u0026mdash; Dev dependencies update\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphadej%2Frc4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphadej%2Frc4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphadej%2Frc4/lists"}