{"id":18655411,"url":"https://github.com/zaincheung/cdk","last_synced_at":"2025-11-05T19:30:24.003Z","repository":{"id":240547568,"uuid":"802871041","full_name":"ZainCheung/cdk","owner":"ZainCheung","description":"Generator and parser for redemption codes","archived":false,"fork":false,"pushed_at":"2024-05-22T16:19:00.000Z","size":34,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-27T14:33:31.098Z","etag":null,"topics":["cdkey","encrypted","generator","golang","parser","shortcode"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/ZainCheung/cdk","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZainCheung.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-19T13:52:51.000Z","updated_at":"2024-12-08T15:25:28.000Z","dependencies_parsed_at":"2024-06-19T14:59:25.039Z","dependency_job_id":"21d4ae21-b666-4fc4-b768-e81e354c4689","html_url":"https://github.com/ZainCheung/cdk","commit_stats":null,"previous_names":["zaincheung/cdk"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZainCheung%2Fcdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZainCheung%2Fcdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZainCheung%2Fcdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZainCheung%2Fcdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZainCheung","download_url":"https://codeload.github.com/ZainCheung/cdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239470227,"owners_count":19644078,"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":["cdkey","encrypted","generator","golang","parser","shortcode"],"created_at":"2024-11-07T07:18:48.161Z","updated_at":"2025-11-05T19:30:23.899Z","avatar_url":"https://github.com/ZainCheung.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cdk\n[中文版](README.zh.md)\n\nGenerator and parser for redemption codes\n\n## Introduction\n\nThis project is a generator and parser for redemption codes. It can generate unique redemption codes based on an increment id, and parse the redemption codes back into the original increment id. This project is suitable for applications that require the generation of large numbers of unique codes in a short period of time.\n\n\n## Getting Started\n\n### Installation\n\nYou can get the project by using the `go get` command:\n\n```bash\ngo get github.com/ZainCheung/cdk\n```\n\n### Usage\nIn your Go code, you can use this project as follows:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"github.com/ZainCheung/cdk\"\n)\n\nfunc main() {\n\t// get a new random secret table\n\trandomSecret, err := cdk.GenerateRandomSecret()\n\tif err != nil {\n\t\treturn\n\t}\n\tvar CharTable = []string{\n\t\t\"A\", \"B\", \"C\", \"D\", \"E\",\n\t\t\"F\", \"G\", \"H\", \"J\", \"K\",\n\t\t\"L\", \"M\", \"N\", \"P\", \"Q\",\n\t\t\"R\", \"S\", \"T\", \"U\", \"V\",\n\t\t\"W\", \"X\", \"Y\", \"Z\", \"2\",\n\t\t\"3\", \"4\", \"5\", \"6\", \"7\",\n\t\t\"8\", \"9\",\n\t}\n\tc := cdk.New(randomSecret, CharTable)\n\t// get a code from an id\n\tcode, err := c.Generate(100001)\n\tif err != nil {\n\t\tlog.Fatalf(\"Generate returned an error: %v\", err)\n\t}\n\tfmt.Println(\"Generated code:\", code)\n\t// get an id from a code\n\tid, err := c.Parse(code)\n\tif err != nil {\n\t\tlog.Fatalf(\"Parse returned an error: %v\", err)\n\t}\n\tfmt.Println(\"Parsed id:\", id)\n}\n```\n\nIn this example, we first generate a random secret table, then create a new `Generater` object with the secret table \nand a character table. We then use the `Generate` method to generate a redemption code based on an increment id, \nand the `Parse` method to parse the redemption code back into the original increment id.\n\n## Performance\n\nThe `Generater` in this project is highly efficient. In benchmark tests, it was able to generate 1,000,000 redemption \ncodes in approximately 3 seconds. This makes it suitable for applications that require the generation of large \nnumbers of unique codes in a short period of time.\n\nPlease note that actual performance may vary depending on the specific hardware and software environment.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaincheung%2Fcdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzaincheung%2Fcdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaincheung%2Fcdk/lists"}