Name | sqids JSON |
Version |
0.5.0
JSON |
| download |
home_page | None |
Summary | Generate YouTube-like ids from numbers. |
upload_time | 2024-08-06 20:41:08 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.6 |
license | MIT License Copyright (c) 2023-present Sqids maintainers. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
sqids
encode
generate
ids
hashids
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# [Sqids Python](https://sqids.org/python)
[![PyPI package](https://badge.fury.io/py/sqids.svg)](https://pypi.org/project/sqids/)
[![Github Actions](https://img.shields.io/github/actions/workflow/status/sqids/sqids-python/tests.yml)](https://github.com/sqids/sqids-python/actions)
[![Downloads](https://img.shields.io/pypi/dm/sqids)](https://pypi.org/project/sqids/)
[Sqids](https://sqids.org/python) (*pronounced "squids"*) is a small library that lets you **generate unique IDs from numbers**. It's good for link shortening, fast & URL-safe ID generation and decoding back into numbers for quicker database lookups.
Features:
- **Encode multiple numbers** - generate short IDs from one or several non-negative numbers
- **Quick decoding** - easily decode IDs back into numbers
- **Unique IDs** - generate unique IDs by shuffling the alphabet once
- **ID padding** - provide minimum length to make IDs more uniform
- **URL safe** - auto-generated IDs do not contain common profanity
- **Randomized output** - Sequential input provides nonconsecutive IDs
- **Many implementations** - Support for [40+ programming languages](https://sqids.org/)
## 🧰 Use-cases
Good for:
- Generating IDs for public URLs (eg: link shortening)
- Generating IDs for internal systems (eg: event tracking)
- Decoding for quicker database lookups (eg: by primary keys)
Not good for:
- Sensitive data (this is not an encryption library)
- User IDs (can be decoded revealing user count)
## 🚀 Getting started
Install the package from PyPI, e. g. with pip:
```bash
pip install sqids
```
Import the `Sqids` class from the `sqids` package:
```python
from sqids import Sqids
sqids = Sqids()
```
## 👩💻 Examples
Simple encode & decode:
```python
sqids = Sqids()
id = sqids.encode([1, 2, 3]) # "86Rf07"
numbers = sqids.decode(id) # [1, 2, 3]
```
> **Note**
> 🚧 Because of the algorithm's design, **multiple IDs can decode back into the same sequence of numbers**. If it's important to your design that IDs are canonical, you have to manually re-encode decoded numbers and check that the generated ID matches.
Enforce a *minimum* length for IDs:
```python
sqids = Sqids(min_length=10)
id = sqids.encode([1, 2, 3]) # "86Rf07xd4z"
numbers = sqids.decode(id) # [1, 2, 3]
```
Randomize IDs by providing a custom alphabet:
```python
sqids = Sqids(alphabet="FxnXM1kBN6cuhsAvjW3Co7l2RePyY8DwaU04Tzt9fHQrqSVKdpimLGIJOgb5ZE")
id = sqids.encode([1, 2, 3]) # "B4aajs"
numbers = sqids.decode(id) # [1, 2, 3]
```
Prevent specific words from appearing anywhere in the auto-generated IDs:
```python
sqids = Sqids(blocklist=["86Rf07"])
id = sqids.encode([1, 2, 3]) # "se8ojk"
numbers = sqids.decode(id) # [1, 2, 3]
```
## 📝 License
[MIT](LICENSE)
Raw data
{
"_id": null,
"home_page": null,
"name": "sqids",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "sqids, encode, generate, ids, hashids",
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/52/ab/1e934252eef4c8583dbe1d5c5c140c382f8e8e6d14ba65ecb7915f508a67/sqids-0.5.0.tar.gz",
"platform": null,
"description": "# [Sqids Python](https://sqids.org/python)\n\n[![PyPI package](https://badge.fury.io/py/sqids.svg)](https://pypi.org/project/sqids/)\n[![Github Actions](https://img.shields.io/github/actions/workflow/status/sqids/sqids-python/tests.yml)](https://github.com/sqids/sqids-python/actions)\n[![Downloads](https://img.shields.io/pypi/dm/sqids)](https://pypi.org/project/sqids/)\n\n[Sqids](https://sqids.org/python) (*pronounced \"squids\"*) is a small library that lets you **generate unique IDs from numbers**. It's good for link shortening, fast & URL-safe ID generation and decoding back into numbers for quicker database lookups.\n\nFeatures:\n\n- **Encode multiple numbers** - generate short IDs from one or several non-negative numbers\n- **Quick decoding** - easily decode IDs back into numbers\n- **Unique IDs** - generate unique IDs by shuffling the alphabet once\n- **ID padding** - provide minimum length to make IDs more uniform\n- **URL safe** - auto-generated IDs do not contain common profanity\n- **Randomized output** - Sequential input provides nonconsecutive IDs\n- **Many implementations** - Support for [40+ programming languages](https://sqids.org/)\n\n## \ud83e\uddf0 Use-cases\n\nGood for:\n\n- Generating IDs for public URLs (eg: link shortening)\n- Generating IDs for internal systems (eg: event tracking)\n- Decoding for quicker database lookups (eg: by primary keys)\n\nNot good for:\n\n- Sensitive data (this is not an encryption library)\n- User IDs (can be decoded revealing user count)\n\n## \ud83d\ude80 Getting started\n\nInstall the package from PyPI, e. g. with pip:\n\n```bash\npip install sqids\n```\n\nImport the `Sqids` class from the `sqids` package:\n\n```python\nfrom sqids import Sqids\nsqids = Sqids()\n```\n\n## \ud83d\udc69\u200d\ud83d\udcbb Examples\n\nSimple encode & decode:\n\n```python\nsqids = Sqids()\nid = sqids.encode([1, 2, 3]) # \"86Rf07\"\nnumbers = sqids.decode(id) # [1, 2, 3]\n```\n\n> **Note**\n> \ud83d\udea7 Because of the algorithm's design, **multiple IDs can decode back into the same sequence of numbers**. If it's important to your design that IDs are canonical, you have to manually re-encode decoded numbers and check that the generated ID matches.\n\nEnforce a *minimum* length for IDs:\n\n```python\nsqids = Sqids(min_length=10)\nid = sqids.encode([1, 2, 3]) # \"86Rf07xd4z\"\nnumbers = sqids.decode(id) # [1, 2, 3]\n```\n\nRandomize IDs by providing a custom alphabet:\n\n```python\nsqids = Sqids(alphabet=\"FxnXM1kBN6cuhsAvjW3Co7l2RePyY8DwaU04Tzt9fHQrqSVKdpimLGIJOgb5ZE\")\nid = sqids.encode([1, 2, 3]) # \"B4aajs\"\nnumbers = sqids.decode(id) # [1, 2, 3]\n```\n\nPrevent specific words from appearing anywhere in the auto-generated IDs:\n\n```python\nsqids = Sqids(blocklist=[\"86Rf07\"])\nid = sqids.encode([1, 2, 3]) # \"se8ojk\"\nnumbers = sqids.decode(id) # [1, 2, 3]\n```\n\n## \ud83d\udcdd License\n\n[MIT](LICENSE)\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2023-present Sqids maintainers. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Generate YouTube-like ids from numbers.",
"version": "0.5.0",
"project_urls": {
"Homepage": "https://sqids.org/python"
},
"split_keywords": [
"sqids",
" encode",
" generate",
" ids",
" hashids"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "00e6b324aeb381c3916e7606b73c3c1e98fa889920a0ae75ed460cca512df9bd",
"md5": "8a853315fc8e79a7c9ac0b1ab902cab2",
"sha256": "4c2d1eabf4721e6e18001b1ff2bc0b30d059447ef96f1e1d1fb7f56841814154"
},
"downloads": -1,
"filename": "sqids-0.5.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8a853315fc8e79a7c9ac0b1ab902cab2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 8820,
"upload_time": "2024-08-06T20:41:04",
"upload_time_iso_8601": "2024-08-06T20:41:04.586560Z",
"url": "https://files.pythonhosted.org/packages/00/e6/b324aeb381c3916e7606b73c3c1e98fa889920a0ae75ed460cca512df9bd/sqids-0.5.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "52ab1e934252eef4c8583dbe1d5c5c140c382f8e8e6d14ba65ecb7915f508a67",
"md5": "bd1fb96b1d2d2663130236b0f8c79a07",
"sha256": "647798e7d5bfeb236e7ac4709cfd4cd808630a6c50f80205df17b4c93e560140"
},
"downloads": -1,
"filename": "sqids-0.5.0.tar.gz",
"has_sig": false,
"md5_digest": "bd1fb96b1d2d2663130236b0f8c79a07",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 18043,
"upload_time": "2024-08-06T20:41:08",
"upload_time_iso_8601": "2024-08-06T20:41:08.928496Z",
"url": "https://files.pythonhosted.org/packages/52/ab/1e934252eef4c8583dbe1d5c5c140c382f8e8e6d14ba65ecb7915f508a67/sqids-0.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-06 20:41:08",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "sqids"
}