# Nano ID
[![CircleCI](https://circleci.com/gh/puyuan/py-nanoid/tree/master.svg?style=svg)](https://circleci.com/gh/puyuan/py-nanoid/tree/master)
A tiny, secure, URL-friendly, unique string ID generator for Python.
* __Safe__. It uses cryptographically strong random APIs and tests distribution of symbols;
* __Compact__. It uses a larger alphabet than UUID (A-Za-z0-9_-). So ID size was reduced from 36 to 21 symbols.
## Usage
Install Nano ID using pip:
```
pip install nanoid
```
### Normal
The main module uses URL-friendly symbols (A-Za-z0-9_-) and returns an ID with 21 characters (to have a collision probability similar to UUID v4).
```python
from nanoid import generate
generate() # => NDzkGoTCdRcaRyt7GOepg
```
Symbols `-,.()` are not encoded in the URL. If used at the end of a link they could be identified as a punctuation symbol.
If you want to reduce ID length (and increase collisions probability), you can pass the length as an argument.
```python
from nanoid import generate
generate(size=10) # => "IRFa-VaY2b"
```
Don’t forget to check the safety of your ID length in ID [collision probability calculator](https://zelark.github.io/nano-id-cc/).
## Custom Alphabet or Length
If you want to change the ID's alphabet or length you can use the internal generate module.
```python
from nanoid import generate
generate('1234567890abcdef', 10) # => "4f9zd13a42"
```
Non-secure API is also available:
```python
from nanoid import non_secure_generate
non_secure_generate('1234567890abcdef', 10)
```
## Tools
* [ID size calculator](https://zelark.github.io/nano-id-cc/) to choice smaller ID size depends on your case.
nanoid-dictionary with popular alphabets to use with nanoid/generate;
* [`nanoid-dictionary`](https://github.com/aidarkhanov/py-nanoid-dictionary) with popular alphabets to use.
## Other Programming Languages
* [C#](https://github.com/codeyu/nanoid-net)
* [Clojure and ClojureScript](https://github.com/zelark/nano-id)
* [Crystal](https://github.com/mamantoha/nanoid.cr)
* [Dart](https://github.com/pd4d10/nanoid)
* [Go](https://github.com/matoous/go-nanoid)
* [Elixir](https://github.com/railsmechanic/nanoid)
* [Haskell](https://github.com/4e6/nanoid-hs)
* [Java](https://github.com/aventrix/jnanoid)
* [JavaScript](https://github.com/ai/nanoid)
* [Nim](https://github.com/icyphox/nanoid.nim)
* [PHP](https://github.com/hidehalo/nanoid-php)
* [Ruby](https://github.com/radeno/nanoid.rb)
* [Rust](https://github.com/nikolay-govorov/nanoid)
* [Swift](https://github.com/antiflasher/NanoID)
## Changelog
- v2.0.0
- Replace ~ to - in default alphabet
- Add non-secure fast generator
- Reduce default characters from 22 to 21
- v0.3.0
- Fix array out of bound error.
## Credits
- Andrey Sitnik for [Nano ID](https://github.com/ai/nanoid);
- [Dair Aidarkhanov](https://github.com/aidarkhanov) for main contribution to v2.0, and adding test cases.
- Aleksandr Zhuravlev for [ID collision probability](https://zelark.github.io/nano-id-cc/).
Raw data
{
"_id": null,
"home_page": "https://github.com/puyuan/py-nanoid",
"name": "nanoid",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Paul Yuan",
"author_email": "puyuan1@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/b7/9d/0250bf5935d88e214df469d35eccc0f6ff7e9db046fc8a9aeb4b2a192775/nanoid-2.0.0.tar.gz",
"platform": "",
"description": "# Nano ID\n\n[![CircleCI](https://circleci.com/gh/puyuan/py-nanoid/tree/master.svg?style=svg)](https://circleci.com/gh/puyuan/py-nanoid/tree/master)\n\nA tiny, secure, URL-friendly, unique string ID generator for Python.\n\n* __Safe__. It uses cryptographically strong random APIs and tests distribution of symbols;\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## Usage\n\nInstall Nano ID using pip:\n\n```\npip install nanoid\n```\n\n### Normal\n\nThe main module uses URL-friendly symbols (A-Za-z0-9_-) and returns an ID with 21 characters (to have a collision probability similar to UUID v4).\n\n\n```python\nfrom nanoid import generate\n\ngenerate() # => NDzkGoTCdRcaRyt7GOepg\n```\n\nSymbols `-,.()` are not encoded in the URL. If used at the end of a link they could be identified as a punctuation symbol.\n\nIf you want to reduce ID length (and increase collisions probability), you can pass the length as an argument.\n\n```python\nfrom nanoid import generate\n\ngenerate(size=10) # => \"IRFa-VaY2b\"\n\n```\n\nDon\u2019t forget to check the safety of your ID length in ID [collision probability calculator](https://zelark.github.io/nano-id-cc/).\n\n\n## Custom Alphabet or Length\n\nIf you want to change the ID's alphabet or length you can use the internal generate module.\n\n```python\nfrom nanoid import generate\n\ngenerate('1234567890abcdef', 10) # => \"4f9zd13a42\"\n```\n\nNon-secure API is also available:\n\n```python\nfrom nanoid import non_secure_generate\n\nnon_secure_generate('1234567890abcdef', 10)\n```\n\n## Tools\n\n* [ID size calculator](https://zelark.github.io/nano-id-cc/) to choice smaller ID size depends on your case.\nnanoid-dictionary with popular alphabets to use with nanoid/generate;\n* [`nanoid-dictionary`](https://github.com/aidarkhanov/py-nanoid-dictionary) with popular alphabets to use.\n\n\n\n## Other Programming Languages\n\n* [C#](https://github.com/codeyu/nanoid-net)\n* [Clojure and ClojureScript](https://github.com/zelark/nano-id)\n* [Crystal](https://github.com/mamantoha/nanoid.cr)\n* [Dart](https://github.com/pd4d10/nanoid)\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* [JavaScript](https://github.com/ai/nanoid)\n* [Nim](https://github.com/icyphox/nanoid.nim)\n* [PHP](https://github.com/hidehalo/nanoid-php)\n* [Ruby](https://github.com/radeno/nanoid.rb)\n* [Rust](https://github.com/nikolay-govorov/nanoid)\n* [Swift](https://github.com/antiflasher/NanoID)\n\n\n## Changelog\n- v2.0.0\n - Replace ~ to - in default alphabet\n - Add non-secure fast generator\n - Reduce default characters from 22 to 21\n- v0.3.0\n - Fix array out of bound error.\n\n## Credits\n\n- Andrey Sitnik for [Nano ID](https://github.com/ai/nanoid);\n- [Dair Aidarkhanov](https://github.com/aidarkhanov) for main contribution to v2.0, and adding test cases.\n- Aleksandr Zhuravlev for [ID collision probability](https://zelark.github.io/nano-id-cc/).\n\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A tiny, secure, URL-friendly, unique string ID generator for Python",
"version": "2.0.0",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "4a367b47e3baea9e7fe25adee4efc6f7",
"sha256": "90aefa650e328cffb0893bbd4c236cfd44c48bc1f2d0b525ecc53c3187b653bb"
},
"downloads": -1,
"filename": "nanoid-2.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4a367b47e3baea9e7fe25adee4efc6f7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5844,
"upload_time": "2018-11-20T14:45:50",
"upload_time_iso_8601": "2018-11-20T14:45:50.165979Z",
"url": "https://files.pythonhosted.org/packages/2e/0d/8630f13998638dc01e187fadd2e5c6d42d127d08aeb4943d231664d6e539/nanoid-2.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "84e2b2db9264e5e0ee9c13481ff46903",
"sha256": "5a80cad5e9c6e9ae3a41fa2fb34ae189f7cb420b2a5d8f82bd9d23466e4efa68"
},
"downloads": -1,
"filename": "nanoid-2.0.0.tar.gz",
"has_sig": false,
"md5_digest": "84e2b2db9264e5e0ee9c13481ff46903",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3290,
"upload_time": "2018-11-20T14:45:51",
"upload_time_iso_8601": "2018-11-20T14:45:51.578634Z",
"url": "https://files.pythonhosted.org/packages/b7/9d/0250bf5935d88e214df469d35eccc0f6ff7e9db046fc8a9aeb4b2a192775/nanoid-2.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2018-11-20 14:45:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "puyuan",
"github_project": "py-nanoid",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"circle": true,
"requirements": [
{
"name": "pytest",
"specs": [
[
"==",
"3.10.0"
]
]
},
{
"name": "flake8",
"specs": [
[
"==",
"3.6.0"
]
]
}
],
"lcname": "nanoid"
}