{"id":18655414,"url":"https://github.com/zaincheung/cdk-js","last_synced_at":"2026-01-24T06:46:10.206Z","repository":{"id":252635872,"uuid":"840906764","full_name":"ZainCheung/cdk-js","owner":"ZainCheung","description":"Generator and parser for redemption codes for javascript","archived":false,"fork":false,"pushed_at":"2024-08-12T11:02:01.000Z","size":82,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T15:50:49.116Z","etag":null,"topics":["cdkey","generator","javascript","nodejs","npm","parser","shortcode","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/cdkey-js","language":"JavaScript","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-08-11T03:53:06.000Z","updated_at":"2024-08-13T02:39:45.000Z","dependencies_parsed_at":"2024-08-11T12:25:59.102Z","dependency_job_id":"c3280845-5d50-49af-8e2e-513074006443","html_url":"https://github.com/ZainCheung/cdk-js","commit_stats":null,"previous_names":["zaincheung/cdk-js"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZainCheung%2Fcdk-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZainCheung%2Fcdk-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZainCheung%2Fcdk-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZainCheung%2Fcdk-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZainCheung","download_url":"https://codeload.github.com/ZainCheung/cdk-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248449853,"owners_count":21105577,"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","generator","javascript","nodejs","npm","parser","shortcode","typescript"],"created_at":"2024-11-07T07:18:48.201Z","updated_at":"2026-01-24T06:46:10.169Z","avatar_url":"https://github.com/ZainCheung.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cdk-js\n[中文版](README.zh.md)\n\nGenerator and parser for redemption codes for javascript\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 `npm` or `pnpm` or `yarn` command:\n\n```bash\nnpm i cdkey-js\n```\n\n### Usage\nIn your node.js project, you can use this project as follows:\n\n```typescript\nimport { Cdk, CdkI, GenerateRandomSecret } from \"cdkey-js\";\n// or \n// const {Cdk, CdkI, GenerateRandomSecret} = require('cdkey-js/dist/cjs');\n\nconst ExampleCharTable: string[] = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789'.split('');\n\n// In practice, please generate a key table in advance, not at runtime.\n// GenerateRandomSecret(true); will generate a random key table and print it to the console.\n// then you can copy the key table to your code.\nconst cdk: CdkI = new Cdk(GenerateRandomSecret(), ExampleCharTable);\n\nexport async function TestCdk() {\n    const incrementID = 123456;\n    try {\n        const generatedCode = cdk.generate(incrementID);\n        console.log('Generated Code:', generatedCode);\n\n        const parsedID = cdk.parse(generatedCode);\n        console.log('Parsed ID:', parsedID);\n\n        const batchCodes = cdk.batchGenerate(incrementID, 5);\n        console.log('Batch Generated Codes:', batchCodes);\n    } catch (error) {\n        console.error('Error:', error);\n    }\n}\n\n```\n\nIn this example, we first generate a random secret table, then create a new `cdk` 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-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzaincheung%2Fcdk-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaincheung%2Fcdk-js/lists"}