{"id":22031091,"url":"https://github.com/russbaz/cuid2","last_synced_at":"2025-06-14T22:36:52.430Z","repository":{"id":241863619,"uuid":"808032249","full_name":"RussBaz/cuid2","owner":"RussBaz","description":"cuid2 implemented in swift","archived":false,"fork":false,"pushed_at":"2024-05-30T10:56:48.000Z","size":5,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T05:03:26.508Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","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/RussBaz.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":"2024-05-30T08:46:38.000Z","updated_at":"2024-06-12T13:21:40.000Z","dependencies_parsed_at":"2024-05-30T11:50:01.307Z","dependency_job_id":"260ed33c-8ca1-4734-b1d9-bc7b8d721c57","html_url":"https://github.com/RussBaz/cuid2","commit_stats":null,"previous_names":["russbaz/cuid2"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RussBaz%2Fcuid2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RussBaz%2Fcuid2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RussBaz%2Fcuid2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RussBaz%2Fcuid2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RussBaz","download_url":"https://codeload.github.com/RussBaz/cuid2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252874355,"owners_count":21817811,"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":[],"created_at":"2024-11-30T08:14:14.312Z","updated_at":"2025-05-07T12:22:34.067Z","avatar_url":"https://github.com/RussBaz.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# _cuid2_ in Swift\n\nThe original implementation in js: [https://github.com/paralleldrive/cuid2](https://github.com/paralleldrive/cuid2)\n\n`cuid2` is a possible replacement to globally unique identifiers such as UUID and such. The length of such an id is configurable and can be easier to copy-paste manually.\n\nHere is an example of the `cuid2` with its default length: `lnapog2xtrbfatrw5qtrpvs6`.\n\nTo learn more, please follow the link to the reference implementation in javascript.\n\n## Installation\n\nPlease add this dependency to your `Package.swift` to use this library:\n\n```swift\n.package(url: \"https://github.com/RussBaz/cuid2.git\", from: \"0.0.1\"),\n```\n\nand then add the dependency to the target:\n\n```swift\n.product(name: \"cuid2\", package: \"cuid2\"),\n```\n\n## How to use\n\n### As a library\n\n```swift\nimport cuid2\n\nlet id = createId() // quickest way to create a one off id\nisCuid2(id: id) // to verify if the string can possibly be cuid2\n\n// Alternatively, you can customise how the ids a generated\n// by providing a custom session counter, cuid length and a custom fingerprint\nfunc createId(counter: Cuid2SessionCounter? = nil, length: Int? = nil, fingerprint: String? = nil) -\u003e String { }\n\n// If you need to create many ids\n// 1. please create an instance of the generator\nstruct Cuid2Generator {\n    // other code omitted\n\n    init(counter: Cuid2SessionCounter? = nil, length: Int? = nil, fingerprint: String? = nil) { }\n\n    // 2. and then use this method to create an array of ids\n    func generate(times: Int) -\u003e [String] { }\n\n    // skipping more code\n}\n```\n\n### As a CLI tool\n\nClone the repository, build the release build with `swift build -c release` from the project root. The `cuid2cli` is now ready for use in the `.build/\u003ctarget-arch-platform\u003e/release/` folder. Move it or copy it into the target destination.\n\n```\nUSAGE: tool [--count \u003ccount\u003e] [--include-line-number] [--length \u003clength\u003e] [--fingerprint \u003cfingerprint\u003e]\n\nOPTIONS:\n  -c, --count \u003ccount\u003e     The number of times to repeat 'cuid2'. (default: 1)\n  -i, --include-line-number\n                          Include a line number with each repetition.\n  -l, --length \u003clength\u003e   The 'cuid2' length in characters.\n  -f, --fingerprint \u003cfingerprint\u003e\n                          The custom fingerprint.\n  -h, --help              Show help information.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frussbaz%2Fcuid2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frussbaz%2Fcuid2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frussbaz%2Fcuid2/lists"}