friendly-id


Namefriendly-id JSON
Version 0.3.3 PyPI version JSON
download
home_page
Summaryfriendly-id is a Python library to generate really unique and url friendly IDs based on UUID and base62
upload_time2023-10-08 13:42:27
maintainer
docs_urlNone
author
requires_python>=3.5
licenseCopyright 2022 Junlin Zhou 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 uuid friendly-id
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Friendly Id

> version 0.3.3

[![test friendly-id](https://github.com/edwardzjl/friendly-id/actions/workflows/test.yml/badge.svg)](https://github.com/edwardzjl/friendly-id/actions/workflows/test.yml)

Inspired by [FriendlyID](https://github.com/Devskiller/friendly-id)

What is the FriendlyId library?
--
The FriendlyId library converts a given UUID (with 36 characters) to a URL-friendly ID (a "FriendlyId") which is based on Base62 (with a maximum of 22 characters), as in the example below:


    UUID                                        Friendly ID

    c3587ec5-0976-497f-8374-61e0c2ea3da5   ->   5wbwf6yUxVBcr48AMbz9cb
    |                                           |                              
    36 characters                               22 characters or less

In addition, this library allows to:


* convert from a FriendlyId back to the original UUID; and
* create a new, random FriendlyId

Why use a FriendlyId?
--
Universal Unique IDs (UUIDs) provide a non-sequential and unique identifier that can be generated separately from the source database. As a result, it is not possible to guess either the previous or next identifier. That's great, but, to achieve this level of security, a UUID is long (128 bits long) and looks ugly (36 alphanumeric characters including four hyphens which are added to make it easier to read the UUID), as in this example: `123e4567-e89b-12d3-a456-426655440000`.

Such a format is:

* difficult to read (especially if it is part of a URL)
* difficult to remember
* cannot be copied with just two mouse-clicks (you have to select manually the start and end positions)
* can easily become broken across lines when it is copied, pasted, edited, or sent.

FriendlyId library solves these problems by converting a given UUID using Base62 with alphanumeric characters in the range [0-9A-Za-z] into a FriendlyId which consists of a maximum of 22 characters (but in fact often contains fewer characters).

Usage
---

Python Package
----
FriendlyId can be installed through PyPI:

```bash
python -m pip install friendly-id
```

Generate a FriendlyId
```python
from friendly_id import friendly_id

id: str = friendly_id(),
```

Convert UUID to FriendlyId
```python
import uuid
from friendly_id import encode

uid = uuid.uuid4()
id: str = encode(uid),
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "friendly-id",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": "",
    "keywords": "uuid,friendly-id",
    "author": "",
    "author_email": "Junlin Zhou <jameszhou2108@hotmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/da/3a/f70ca296d40de9e7522d8b08e8eb5afdb00402ad96bb734d706b5e5e4439/friendly-id-0.3.3.tar.gz",
    "platform": null,
    "description": "# Friendly Id\n\n> version 0.3.3\n\n[![test friendly-id](https://github.com/edwardzjl/friendly-id/actions/workflows/test.yml/badge.svg)](https://github.com/edwardzjl/friendly-id/actions/workflows/test.yml)\n\nInspired by [FriendlyID](https://github.com/Devskiller/friendly-id)\n\nWhat is the FriendlyId library?\n--\nThe FriendlyId library converts a given UUID (with 36 characters) to a URL-friendly ID (a \"FriendlyId\") which is based on Base62 (with a maximum of 22 characters), as in the example below:\n\n\n    UUID                                        Friendly ID\n\n    c3587ec5-0976-497f-8374-61e0c2ea3da5   ->   5wbwf6yUxVBcr48AMbz9cb\n    |                                           |                              \n    36 characters                               22 characters or less\n\nIn addition, this library allows to:\n\n\n* convert from a FriendlyId back to the original UUID; and\n* create a new, random FriendlyId\n\nWhy use a FriendlyId?\n--\nUniversal Unique IDs (UUIDs) provide a non-sequential and unique identifier that can be generated separately from the source database. As a result, it is not possible to guess either the previous or next identifier. That's great, but, to achieve this level of security, a UUID is long (128 bits long) and looks ugly (36 alphanumeric characters including four hyphens which are added to make it easier to read the UUID), as in this example: `123e4567-e89b-12d3-a456-426655440000`.\n\nSuch a format is:\n\n* difficult to read (especially if it is part of a URL)\n* difficult to remember\n* cannot be copied with just two mouse-clicks (you have to select manually the start and end positions)\n* can easily become broken across lines when it is copied, pasted, edited, or sent.\n\nFriendlyId library solves these problems by converting a given UUID using Base62 with alphanumeric characters in the range [0-9A-Za-z] into a FriendlyId which consists of a maximum of 22 characters (but in fact often contains fewer characters).\n\nUsage\n---\n\nPython Package\n----\nFriendlyId can be installed through PyPI:\n\n```bash\npython -m pip install friendly-id\n```\n\nGenerate a FriendlyId\n```python\nfrom friendly_id import friendly_id\n\nid: str = friendly_id(),\n```\n\nConvert UUID to FriendlyId\n```python\nimport uuid\nfrom friendly_id import encode\n\nuid = uuid.uuid4()\nid: str = encode(uid),\n```\n",
    "bugtrack_url": null,
    "license": "Copyright 2022 Junlin Zhou  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": "friendly-id is a Python library to generate really unique and url friendly IDs based on UUID and base62",
    "version": "0.3.3",
    "project_urls": {
        "homepage": "https://github.com/edwardzjl/friendly-id",
        "repository": "https://github.com/edwardzjl/friendly-id"
    },
    "split_keywords": [
        "uuid",
        "friendly-id"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7b0020cfc25e8f6da985e2f6d22db5f5a0bbb394e2cda5ea41dc65d2324dabd0",
                "md5": "26d1484d0d6f8488af07f85f82887b2b",
                "sha256": "bfffc26cf6b2d89b4e19832594e105374b251180905e0c7ec2a012a0733395d1"
            },
            "downloads": -1,
            "filename": "friendly_id-0.3.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "26d1484d0d6f8488af07f85f82887b2b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5",
            "size": 5139,
            "upload_time": "2023-10-08T13:42:26",
            "upload_time_iso_8601": "2023-10-08T13:42:26.909880Z",
            "url": "https://files.pythonhosted.org/packages/7b/00/20cfc25e8f6da985e2f6d22db5f5a0bbb394e2cda5ea41dc65d2324dabd0/friendly_id-0.3.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "da3af70ca296d40de9e7522d8b08e8eb5afdb00402ad96bb734d706b5e5e4439",
                "md5": "f1e728be052f10128451f3df97f82267",
                "sha256": "cd44d50868b287adfacaef5d4540d9ccae5b85908580461f4bdf7ab1c03fbb75"
            },
            "downloads": -1,
            "filename": "friendly-id-0.3.3.tar.gz",
            "has_sig": false,
            "md5_digest": "f1e728be052f10128451f3df97f82267",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 4390,
            "upload_time": "2023-10-08T13:42:27",
            "upload_time_iso_8601": "2023-10-08T13:42:27.987355Z",
            "url": "https://files.pythonhosted.org/packages/da/3a/f70ca296d40de9e7522d8b08e8eb5afdb00402ad96bb734d706b5e5e4439/friendly-id-0.3.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-08 13:42:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "edwardzjl",
    "github_project": "friendly-id",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "friendly-id"
}
        
Elapsed time: 0.12399s