{"id":13509362,"url":"https://github.com/railsmechanic/nanoid","last_synced_at":"2025-05-15T01:10:04.397Z","repository":{"id":45798178,"uuid":"116025738","full_name":"railsmechanic/nanoid","owner":"railsmechanic","description":"Elixir port of NanoID, a secure and URL-friendly unique ID generator. https://hex.pm/packages/nanoid","archived":false,"fork":false,"pushed_at":"2025-02-13T07:22:42.000Z","size":70,"stargazers_count":228,"open_issues_count":1,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-13T23:54:06.818Z","etag":null,"topics":["elixir-port","identifier","idgenerator","token"],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/railsmechanic.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-02T14:50:43.000Z","updated_at":"2025-03-20T10:57:03.000Z","dependencies_parsed_at":"2025-03-01T10:01:17.216Z","dependency_job_id":"04d7b074-dac1-42d1-b4f2-b4f099c8d2bb","html_url":"https://github.com/railsmechanic/nanoid","commit_stats":{"total_commits":54,"total_committers":7,"mean_commits":7.714285714285714,"dds":0.2407407407407407,"last_synced_commit":"41c6285110c8e83f4dcccb9a2000d1218b70abe0"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/railsmechanic%2Fnanoid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/railsmechanic%2Fnanoid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/railsmechanic%2Fnanoid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/railsmechanic%2Fnanoid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/railsmechanic","download_url":"https://codeload.github.com/railsmechanic/nanoid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254254043,"owners_count":22039792,"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":["elixir-port","identifier","idgenerator","token"],"created_at":"2024-08-01T02:01:06.657Z","updated_at":"2025-05-15T01:09:59.390Z","avatar_url":"https://github.com/railsmechanic.png","language":"Elixir","funding_links":[],"categories":["Text and Numbers","Elixir"],"sub_categories":[],"readme":"# Nanoid port for Elixir [![Build Status](https://travis-ci.org/railsmechanic/nanoid.svg?branch=master)](https://travis-ci.org/railsmechanic/nanoid)\n\nElixir port of NanoID ([https://github.com/ai/nanoid](https://github.com/ai/nanoid)), a tiny, secure URL-friendly unique string ID generator.\n\n**Safe.** It uses cryptographically strong random APIs and tests distribution of symbols.\n\n**Compact.** It uses a larger alphabet than UUID `(A-Za-z0-9_-)`. So ID size was reduced from 36 to 21 symbols.\n\n\n## Installation\n\nThe package can be installed as Hex package:\n\n  1. Add nanoid to your list of dependencies in `mix.exs`:\n\n  ```elixir\n  def deps do\n    [{:nanoid, \"~\u003e 2.1.0\"}]\n  end\n  ```\n\n  2. Run `mix deps.get` to fetch the package from hex\n\n## Introducing a new generator\nWith version 2.0.0 of nanoid, **[@ai](https://github.com/ai/nanoid)** introduces a new `non-secure` way of creating NanoIDs.\nIn order to keep this port close to the original, this possibility was also introduced in this port.\nTo ensure a certain level of security, `nanoid` uses per default the `secure` token generator.\nBut according to your preferences, if you don't need \"cryptographically strong random tokens\", just use the `non-secure` token generator.\n\n\n## Configuration\nStarting with version 2.0.0 of nanoid for Elixir it's possible to use `config.exs` to configure nanoid defaults e.g. for different environments.\n\n```elixir\nconfig :nanoid,\n  size: 21,\n  alphabet: \"_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n```\n\nAfter changing configuration, remember to re-compile nanoid with following command:\n\n```sh\n$ mix deps.compile nanoid --force\n```\n\n\u003e Why re-compile? Continuously reading the configuration via `Application.get_env/3` has [a significant effect](https://github.com/railsmechanic/nanoid/issues/6#issuecomment-644774144) on the speed of nanoid. [Compiling the default configuration into byte-code](https://github.com/railsmechanic/nanoid/blob/d606738d3c8bf002121ea3249f35d2c648ffa6e2/lib/nanoid/configuration.ex#L7) will eliminate the effect.\n\n## Usage\n\n### Using the \"secure\" (default) generator\n#### Generate secure NanoIDs of custom size by using the default alphabet\n\nGenerate a secure NanoID with the default size of 21 characters.\n```elixir\niex\u003e Nanoid.generate()\n\"mJUHrGXZBZpNX50x2xkzf\"\n```\n\nGenerate a secure NanoID with a custom size of 64 characters.\n```elixir\niex\u003e Nanoid.generate(64)\n\"wk9fsUrhK9k~MxY0hLazRKpcSlic8XYDFusks7Jb8FwCVnoQaKFSPsmmLHzP7qCX\"\n```\n\n#### Generate secure NanoIDs of custom size by using a custom alphabet\n\nGenerate a secure NanoID with the default size of 21 characters and an individual alphabet.\n```elixir\niex\u003e Nanoid.generate(21, \"abcdef123\")\n\"d1dcd2dee333cae1bfdea\"\n```\n\nGenerate a secure NanoID with custom size of 64 characters and an individual alphabet.\n```elixir\niex\u003e Nanoid.generate(64, \"abcdef123\")\n\"aabbaca3c11accca213babed2bcd1213efb3e3fa1ad23ecbf11c2ffc123f3bbe\"\n```\n\n### Using the \"non-secure\" generator\n#### Generate non-secure NanoIDs of custom size by using the default alphabet\n\nGenerate a non-secure NanoID with the default size of 21 characters.\n```elixir\niex\u003e Nanoid.generate_non_secure()\n\"YBctoD1RuZqv0DLfzDxl2\"\n```\n\nGenerate a non-secure NanoID with a custom size of 64 characters.\n```elixir\niex\u003e Nanoid.generate_non_secure(64)\n\"D2WBHGWQOVds4YKuErmOGJ-oYfp5rik5Z-qo7kN1Dw3gv_1qQs6POmhqZdabkf8s\"\n```\n\n#### Generate non-secure NanoIDs of custom size and with a custom alphabet\n\nGenerate a non-secure NanoID with the default size of 21 characters and an individual alphabet.\n```elixir\niex\u003e Nanoid.generate_non_secure(21, \"abcdef123\")\n\"b12c2fac2bdbcdfcfb2da\"\n```\n\nGenerate a non-secure NanoID with custom size of 64 characters and an individual alphabet.\n```elixir\niex\u003e Nanoid.generate_non_secure(64, \"abcdef123\")\n\"dfc1ed3ea22bed1c3c2df2eb21bbd33efdfae3abd3ca2abcca1efcfbf31a3b3f\"\n```\n\n## License\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frailsmechanic%2Fnanoid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frailsmechanic%2Fnanoid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frailsmechanic%2Fnanoid/lists"}