{"id":24773105,"url":"https://github.com/asimihsan/permutation-iterator-rs","last_synced_at":"2025-10-11T22:30:29.067Z","repository":{"id":49531689,"uuid":"228111069","full_name":"asimihsan/permutation-iterator-rs","owner":"asimihsan","description":"A Rust library for iterating over random permutations.","archived":false,"fork":false,"pushed_at":"2021-06-15T20:22:26.000Z","size":73,"stargazers_count":14,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-03T12:45:43.368Z","etag":null,"topics":["feistel-network","random","random-permutations","rust-library"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asimihsan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2019-12-15T01:02:56.000Z","updated_at":"2023-06-24T11:34:04.000Z","dependencies_parsed_at":"2022-07-30T07:07:57.051Z","dependency_job_id":null,"html_url":"https://github.com/asimihsan/permutation-iterator-rs","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/asimihsan/permutation-iterator-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asimihsan%2Fpermutation-iterator-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asimihsan%2Fpermutation-iterator-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asimihsan%2Fpermutation-iterator-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asimihsan%2Fpermutation-iterator-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asimihsan","download_url":"https://codeload.github.com/asimihsan/permutation-iterator-rs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asimihsan%2Fpermutation-iterator-rs/sbom","scorecard":{"id":212164,"data":{"date":"2025-08-11","repo":{"name":"github.com/asimihsan/permutation-iterator-rs","commit":"594e28f1ac19d41e23e3c51d9ba29fa12ab57ee2"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-17T00:56:29.251Z","repository_id":49531689,"created_at":"2025-08-17T00:56:29.251Z","updated_at":"2025-08-17T00:56:29.251Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279009071,"owners_count":26084549,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["feistel-network","random","random-permutations","rust-library"],"created_at":"2025-01-29T04:38:48.484Z","updated_at":"2025-10-11T22:30:28.741Z","avatar_url":"https://github.com/asimihsan.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# permutation-iterator\n\n[![Build Status](https://travis-ci.com/asimihsan/permutation-iterator-rs.svg?branch=master)](https://travis-ci.com/asimihsan/permutation-iterator-rs)\n[![Crate](https://img.shields.io/crates/v/permutation_iterator.svg)](https://crates.io/crates/permutation_iterator)\n[![API](https://docs.rs/permutation_iterator/badge.svg)](https://docs.rs/permutation_iterator)\n![License](https://img.shields.io/crates/l/permutation_iterator.svg)\n\n\nA Rust library for iterating over random permutations without fully materializing them into memory.\n\n`permutation-iterator` lets you iterate over a random permutation, for example the values `[0, 1, 2, 3, 4, 5]` in a\nrandom order. It does so in constant space; it does not fully instantiate the values in memory then shuffle them.\n\n## Usage\n\nAdd this to your `Cargo.toml`:\n\n```toml\n[dependencies]\npermutation_iterator = \"0.1.2\"\n```\n\n## Example\n\n### Random, single integer range\n\nHere is how to iterate over a random permutation of integers in the range `[0, max)`, i.e. `0` inclusive to `max`\nexclusive. Every time you run this you will get a different permutation.\n\n```rust\nuse permutation_iterator::Permutor;\n\nfn main() {\n    let max = 10;\n    let permutor = Permutor::new(max);\n    for permuted in permutor {\n        println!(\"{}\", permuted);\n    }\n}\n```\n\n### Deterministic, single integer range\n\nYou can also pass in a `key` in order to iterate over a deterministically random permutation. Every time you run this\nyou will get the same permutation:\n\n```rust\nuse permutation_iterator::Permutor;\n\nfn main() {\n    let max = 10;\n    let key: [u8; 32] = [0xBA; 32];\n    let permutor = Permutor::new_with_slice_key(max, key);\n    for permuted in permutor {\n        println!(\"{}\", permuted);\n    }\n}\n```\n\n### Random, pair of integers\n\nIf you have e.g. two vectors of integers and you want to iterate over a random permutation of pairs from these lists\nyou can use:\n\n```rust\nuse permutation_iterator::RandomPairPermutor;\n\nfn main() {\n    let xs = [1, 2, 3];\n    let ys = [4, 5, 6, 7, 8];\n\n    let permutor = RandomPairPermutor::new(xs.len() as u32, ys.len() as u32);\n    for (i, j) in permutor {\n        println!(\"({}, {})\", xs[i as usize], ys[j as usize]);\n    }\n}\n```\n\n## Implementation details\n\nOne way of generating a random permutation is to shuffle a list. For example, given input integers `[0, 1, 2, 3, 4, 5]`,\none can shuffle it to e.g. `[5, 3, 2, 0, 1, 4]`. Each input element maps to one and only one output element, and\nvice versa (each output element maps to one and only one input element). As you consume the shuffled list from e.g.\nleft to right you're consuming this random permutation.\n\nShuffling is `O(n)` time using the Fisher-Yates algorithm, however it is also `O(n)` space. We need a copy of the\nelements in-memory in order to shuffle them. This is inconvenient if the input range is large, or if the environment\nyou're running on is memory-constrained.\n\nCryptography offers an alternative. Symmetric encryption boils down to mapping a given input to one and only one output,\nwhere the mapping is varied by a single secret key, and vice-versa (each output element maps to one and only one input\nelement). If this **bijective** mapping did not exist we wouldn't be reliably able to retrieve the original input. One\nspecific kind of symmetric encryption uses a **block** cipher (operating on n-bits at a time) implemented using a \n**Feistel network**.\n\nA Feistel network is an extraordinary construct that allows you to use a simple, relatively weak **non-invertible**\nfunction over and over again and become a complicated, relatively strong **invertible permutation**. Hence in\nconstant time we can _encrypt_ inputs as a way of iterating over random permutations. We can similarly _decrypt_\nthe output as a way of _resuming_ permutations.\n\nConsider the example of a bank that is trying to generate unique credit card numbers. Actual credit card numbers need\nto be stored very securely and we would rather not have to look them in order to find the next available number. By\nstoring just a key and the last credit card number generated we can securely and efficiently continue iterating over\nthe random permutation of all credit card numbers, without risking repeats.\n\n## Maintainer notes\n\n### How to release a new version\n\n\n\n## License\n\n`permutation-iterator` is distributed under the terms of the Apache License (Version 2.0). See [LICENSE](LICENSE) for\ndetails.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasimihsan%2Fpermutation-iterator-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasimihsan%2Fpermutation-iterator-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasimihsan%2Fpermutation-iterator-rs/lists"}