{"id":13468842,"url":"https://github.com/skorokithakis/shortuuid","last_synced_at":"2025-12-15T23:48:16.526Z","repository":{"id":37405553,"uuid":"1232822","full_name":"skorokithakis/shortuuid","owner":"skorokithakis","description":"A generator library for concise, unambiguous and URL-safe UUIDs.","archived":false,"fork":false,"pushed_at":"2025-12-01T00:26:35.000Z","size":140,"stargazers_count":2163,"open_issues_count":0,"forks_count":118,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-12-03T10:31:07.008Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.stavros.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skorokithakis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"COPYING","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,"zenodo":null}},"created_at":"2011-01-08T13:00:43.000Z","updated_at":"2025-12-03T01:53:10.000Z","dependencies_parsed_at":"2024-03-11T21:28:16.221Z","dependency_job_id":"e44646d2-8c44-4669-b179-fe0ff5a2e418","html_url":"https://github.com/skorokithakis/shortuuid","commit_stats":{"total_commits":157,"total_committers":36,"mean_commits":4.361111111111111,"dds":0.6050955414012739,"last_synced_commit":"a031e798e160e287fee22bfcfe48ae115d31d26a"},"previous_names":["stochastic-technologies/shortuuid"],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/skorokithakis/shortuuid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skorokithakis%2Fshortuuid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skorokithakis%2Fshortuuid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skorokithakis%2Fshortuuid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skorokithakis%2Fshortuuid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skorokithakis","download_url":"https://codeload.github.com/skorokithakis/shortuuid/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skorokithakis%2Fshortuuid/sbom","scorecard":{"id":829977,"data":{"date":"2025-08-11","repo":{"name":"github.com/skorokithakis/shortuuid","commit":"6843c128cb334c272954cce8f1dce1e9f9bf4054"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.2,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":4,"reason":"Found 11/26 approved changesets -- score normalized to 4","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/pre-commit.yml:1","Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pre-commit.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/skorokithakis/shortuuid/pre-commit.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pre-commit.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/skorokithakis/shortuuid/pre-commit.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/pre-commit.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/skorokithakis/shortuuid/pre-commit.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/skorokithakis/shortuuid/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/skorokithakis/shortuuid/test.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/skorokithakis/shortuuid/test.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:23","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   0 out of   1 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: COPYING:0","Info: FSF or OSI recognized license: BSD 3-Clause \"New\" or \"Revised\" License: COPYING:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 16 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T17:30:30.927Z","repository_id":37405553,"created_at":"2025-08-23T17:30:30.927Z","updated_at":"2025-08-23T17:30:30.927Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27757808,"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","status":"online","status_checked_at":"2025-12-15T02:00:09.782Z","response_time":96,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-07-31T15:01:20.145Z","updated_at":"2025-12-15T23:48:16.519Z","avatar_url":"https://github.com/skorokithakis.png","language":"Python","funding_links":[],"categories":["Text Processing","Python","UUID Like","文本处理","URL Utilities","Text Processing [🔝](#readme)","Data Processing","Uncategorized","Awesome Python"],"sub_categories":["Packages","Uncategorized","Text Processing"],"readme":"Description\n===========\n\n`shortuuid` is a simple python library that generates concise, unambiguous, URL-safe\nUUIDs.\n\nOften, one needs to use non-sequential IDs in places where users will see them, but the\nIDs must be as concise and easy to use as possible.  `shortuuid` solves this problem by\ngenerating uuids using Python's built-in `uuid` module and then translating them to\nbase57 using lowercase and uppercase letters and digits, and removing similar-looking\ncharacters such as l, 1, I, O and 0.\n\n\nInstallation\n------------\n\nTo install `shortuuid` you need:\n\n-   Python 3.6+\n\nIf you have the dependencies, you have multiple options of installation:\n\n-   With pip (preferred), do `pip install shortuuid`.\n-   With setuptools, do `easy_install shortuuid`.\n-   To install the source, download it from\n    https://github.com/stochastic-technologies/shortuuid and run `python setup.py\n    install`.\n\n\nUsage\n-----\n\nTo use `shortuuid`, just import it in your project like so:\n\n```python\n\u003e\u003e\u003e import shortuuid\n```\n\nYou can then generate a short UUID:\n\n```python\n\u003e\u003e\u003e shortuuid.uuid()\n'vytxeTZskVKR7C7WgdSP3d'\n```\n\nIf you prefer a version 5 UUID, you can pass a name (DNS or URL) to the call and it will\nbe used as a namespace (`uuid.NAMESPACE_DNS` or `uuid.NAMESPACE_URL`) for the resulting\nUUID:\n\n```python\n\u003e\u003e\u003e shortuuid.uuid(name=\"example.com\")\n'exu3DTbj2ncsn9tLdLWspw'\n\n\u003e\u003e\u003e shortuuid.uuid(name=\"\u003chttp://example.com\u003e\")\n'shortuuid.uuid(name=\"\u003chttp://example.com\u003e\")'\n```\n\nYou can also generate a cryptographically secure random string (using `os.urandom()`\ninternally) with:\n\n```python\n\u003e\u003e\u003e shortuuid.ShortUUID().random(length=22)\n'RaF56o2r58hTKT7AYS9doj'\n```\n\nTo see the alphabet that is being used to generate new UUIDs:\n\n```python\n\u003e\u003e\u003e shortuuid.get_alphabet()\n'23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'\n```\n\nIf you want to use your own alphabet to generate UUIDs, use `set_alphabet()`:\n\n```python\n\u003e\u003e\u003e shortuuid.set_alphabet(\"aaaaabcdefgh1230123\")\n\u003e\u003e\u003e shortuuid.uuid()\n'0agee20aa1hehebcagddhedddc0d2chhab3b'\n```\n\nThe default alphabet matches the regex `[2-9A-HJ-NP-Za-km-z]{22}`.\n\n`shortuuid` will automatically sort and remove duplicates from your alphabet to ensure\nconsistency:\n\n```python\n\u003e\u003e\u003e shortuuid.get_alphabet()\n'0123abcdefgh'\n```\n\nYou can prevent the alphabet from being sorted by passing the `dont_sort_alphabet`\nkeyword argument to `set_alphabet()`. This option ensures compatibility with different\nimplementations of ShortUUID:\n\n```python\n\u003e\u003e\u003e shortuuid.set_alphabet(\"aaaaabcdefgh1230123\", dont_sort_alphabet=True)\n\u003e\u003e\u003e shortuuid.get_alphabet()\n'abcdefgh1230'\n```\n\nIf the default 22 digits are too long for you, you can get shorter IDs by just\ntruncating the string to the desired length. The IDs won't be universally unique any\nlonger, but the probability of a collision will still be very low.\n\nTo serialize existing UUIDs, use `encode()` and `decode()`:\n\n```python\n\u003e\u003e\u003e import uuid\n\u003e\u003e\u003e u = uuid.uuid4()\n\u003e\u003e\u003e u\nUUID('6ca4f0f8-2508-4bac-b8f1-5d1e3da2247a')\n\n\u003e\u003e\u003e s = shortuuid.encode(u)\n\u003e\u003e\u003e s\n'MLpZDiEXM4VsUryR9oE8uc'\n\n\u003e\u003e\u003e shortuuid.decode(s) == u\nTrue\n\n\u003e\u003e\u003e short = s[:7]\n\u003e\u003e\u003e short\n'MLpZDiE'\n\n\u003e\u003e\u003e h = shortuuid.decode(short)\nUUID('00000000-0000-0000-0000-009a5b27f8b9')\n\n\u003e\u003e\u003e shortuuid.decode(shortuuid.encode(h)) == h\nTrue\n```\n\n\nClass-based usage\n-----------------\n\nIf you need to have various alphabets per-thread, you can use the `ShortUUID` class,\nlike so:\n\n```python\n\u003e\u003e\u003e su = shortuuid.ShortUUID(alphabet=\"01345678\")\n\u003e\u003e\u003e su.uuid()\n'034636353306816784480643806546503818874456'\n\n\u003e\u003e\u003e su.get_alphabet()\n'01345678'\n\n\u003e\u003e\u003e su.set_alphabet(\"21345687654123456\")\n\u003e\u003e\u003e su.get_alphabet()\n'12345678'\n```\n\n\nCommand-line usage\n------------------\n\n`shortuuid` provides a simple way to generate a short UUID in a terminal:\n\n```bash\n$ shortuuid\nfZpeF6gcskHbSpTgpQCkcJ\n```\n\n\nDjango field\n------------\n\n`shortuuid` includes a Django field that generates random short UUIDs by default, for\nyour convenience:\n\n```python\nfrom shortuuid.django_fields import ShortUUIDField\n\nclass MyModel(models.Model):\n    # A primary key ID of length 16 and a short alphabet.\n    id = ShortUUIDField(\n        length=16,\n        max_length=40,\n        prefix=\"id_\",\n        alphabet=\"abcdefg1234\",\n        dont_sort_alphabet=False\n        primary_key=True,\n    )\n\n    # A short UUID of length 22 and the default alphabet.\n    api_key = ShortUUIDField()\n```\n\nThe field is the same as the `CharField`, with a `length` argument (the length of the\nID), an `alphabet` argument, and the `default` argument removed. Everything else is\nexactly the same, e.g. `index`, `help_text`, `max_length`, etc.\n\n\nCompatibility note\n------------------\n\nVersions of ShortUUID prior to 1.0.0 generated UUIDs with their MSB last, i.e. reversed.\nThis was later fixed, but if you have some UUIDs stored as a string with the old method,\nyou need to pass `legacy=True` to `decode()` when converting your strings back to UUIDs.\n\nThat option will go away in the future, so you will want to convert your UUIDs to\nstrings using the new method. This can be done like so:\n\n```python\n\u003e\u003e\u003e new_uuid_str = encode(decode(old_uuid_str, legacy=True))\n```\n\nLicense\n-------\n\n`shortuuid` is distributed under the BSD license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskorokithakis%2Fshortuuid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskorokithakis%2Fshortuuid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskorokithakis%2Fshortuuid/lists"}