{"id":14675838,"url":"https://github.com/mrdimidium/nanoid","last_synced_at":"2026-03-11T15:37:05.328Z","repository":{"id":40689320,"uuid":"115445922","full_name":"mrdimidium/nanoid","owner":"mrdimidium","description":" A tiny, secure, URL-friendly, unique string ID generator for Rust","archived":false,"fork":false,"pushed_at":"2023-06-17T22:58:47.000Z","size":104,"stargazers_count":599,"open_issues_count":6,"forks_count":36,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-01-13T20:58:22.871Z","etag":null,"topics":["id","random","url","uuid"],"latest_commit_sha":null,"homepage":"https://docs.rs/nanoid","language":"Rust","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/mrdimidium.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-12-26T18:31:40.000Z","updated_at":"2026-01-05T09:29:16.000Z","dependencies_parsed_at":"2024-01-14T06:51:01.315Z","dependency_job_id":"3f9babb1-8b69-4af2-9c26-25acd38d9571","html_url":"https://github.com/mrdimidium/nanoid","commit_stats":{"total_commits":92,"total_committers":13,"mean_commits":7.076923076923077,"dds":"0.26086956521739135","last_synced_commit":"8d5bcc41134c74190505c2a8a22b59a5a2ee392e"},"previous_names":["mrdimidium/nanoid","nikolay-govorov/nanoid"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/mrdimidium/nanoid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdimidium%2Fnanoid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdimidium%2Fnanoid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdimidium%2Fnanoid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdimidium%2Fnanoid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrdimidium","download_url":"https://codeload.github.com/mrdimidium/nanoid/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdimidium%2Fnanoid/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30386169,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T14:10:17.325Z","status":"ssl_error","status_checked_at":"2026-03-11T14:09:37.934Z","response_time":84,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["id","random","url","uuid"],"created_at":"2024-09-12T08:01:41.501Z","updated_at":"2026-03-11T15:37:05.291Z","avatar_url":"https://github.com/mrdimidium.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Nano ID\n\n[![Package version](https://img.shields.io/crates/v/nanoid.svg)](https://crates.io/crates/nanoid)\n[![License](https://img.shields.io/badge/license-MIT%20License-blue.svg)](https://github.com/nikolay-govorov/nanoid/blob/main/LICENSE)\n[![Build](https://github.com/nikolay-govorov/nanoid/actions/workflows/test.yml/badge.svg)](https://github.com/nikolay-govorov/nanoid/actions/workflows/test.yml)\n\nA tiny, secure, URL-friendly, unique string ID generator for Rust\n\n```rust\nuse nanoid::nanoid;\n\nfn main() {\n   let id = nanoid!(); //=\u003e \"Yo1Tr9F3iF-LFHX9i9GvA\"\n}\n```\n\n**Safe.** It uses cryptographically strong random APIs\nand guarantees a proper distribution of symbols.\n\n**Compact.** It uses a larger alphabet than UUID (`A-Za-z0-9_-`)\nand has a similar number of unique IDs in just 21 symbols instead of 36.\n\n## Usage\n\n### Install\n\n```toml\n[dependencies]\nnanoid = \"0.4.0\"\n```\n\n### Simple\n\nThe main module uses URL-friendly symbols (`A-Za-z0-9_-`) and returns an ID\nwith 21 characters.\n\n```rust\nuse nanoid::nanoid;\n\nfn main() {\n   let id = nanoid!(); //=\u003e \"Yo1Tr9F3iF-LFHX9i9GvA\"\n}\n```\n\nSymbols `-,.()` are not encoded in the URL. If used at the end of a link\nthey could be identified as a punctuation symbol.\n\n### Custom length\n\nIf you want to reduce ID length (and increase collisions probability),\nyou can pass the length as an argument generate function:\n\n```rust\nuse nanoid::nanoid;\n\nfn main() {\n   let id = nanoid!(10); //=\u003e \"IRFa-VaY2b\"\n}\n```\n\n### Custom Alphabet or Length\n\nIf you want to change the ID's alphabet or length, you can simply pass the\ncustom alphabet to the `nanoid!()` macro as the second parameter:\n\n```rust\nuse nanoid::nanoid;\n\nfn main() {\n    let alphabet: [char; 16] = [\n        '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'a', 'b', 'c', 'd', 'e', 'f'\n    ];\n\n   let id = nanoid!(10, \u0026alphabet); //=\u003e \"4f90d13a42\"\n}\n```\n\nAlphabet must contain 256 symbols or less.\nOtherwise, the generator will not be secure.\n\n### Custom Random Bytes Generator\n\nYou can replace the default safe random generator using the `complex` module.\nFor instance, to use a seed-based generator.\n\n```rust\nuse nanoid::nanoid;\n\nfn random_byte () -\u003e u8 { 0 }\n\nfn main() {\n    fn random (size: usize) -\u003e Vec\u003cu8\u003e {\n        let mut bytes: Vec\u003cu8\u003e = vec![0; size];\n\n        for i in 0..size {\n            bytes[i] = random_byte();\n        }\n\n        bytes\n    }\n\n    nanoid!(10, \u0026['a', 'b', 'c', 'd', 'e', 'f'], random); //=\u003e \"fbaefaadeb\"\n}\n```\n\n`random` function must accept the array size and return an vector\nwith random numbers.\n\nIf you want to use the same URL-friendly symbols with `format`,\nyou can get the default alphabet from the `url` module:\n\n```rust\nuse nanoid::nanoid;\n\nfn random (size: usize) -\u003e Vec\u003cu8\u003e {\n    let result: Vec\u003cu8\u003e = vec![0; size];\n\n    result\n}\n\nfn main() {\n    nanoid!(10, \u0026nanoid::alphabet::SAFE, random); //=\u003e \"93ce_Ltuub\"\n}\n```\n\n## Other Programming Languages\n\n* [JS](https://github.com/ai/nanoid)\n* [C#](https://github.com/codeyu/nanoid-net)\n* [Crystal](https://github.com/mamantoha/nanoid.cr)\n* [Go](https://github.com/matoous/go-nanoid)\n* [Elixir](https://github.com/railsmechanic/nanoid)\n* [Haskell](https://github.com/4e6/nanoid-hs)\n* [Java](https://github.com/aventrix/jnanoid)\n* [Nim](https://github.com/icyphox/nanoid.nim)\n* [PHP](https://github.com/hidehalo/nanoid-php)\n* [Python](https://github.com/puyuan/py-nanoid)\n* [Ruby](https://github.com/radeno/nanoid.rb)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrdimidium%2Fnanoid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrdimidium%2Fnanoid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrdimidium%2Fnanoid/lists"}