{"id":43859118,"url":"https://github.com/marksalpeter/token","last_synced_at":"2026-02-06T09:45:16.875Z","repository":{"id":8848106,"uuid":"43962087","full_name":"marksalpeter/token","owner":"marksalpeter","description":"A simple base62 encoded token library for go, ideal for short url services.","archived":false,"fork":false,"pushed_at":"2022-04-16T17:43:53.000Z","size":27,"stargazers_count":67,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-11T08:15:44.374Z","etag":null,"topics":["base62","encoder","go","golang","primary-key"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/marksalpeter.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}},"created_at":"2015-10-09T14:53:48.000Z","updated_at":"2024-07-09T09:49:14.000Z","dependencies_parsed_at":"2022-08-07T05:00:09.131Z","dependency_job_id":null,"html_url":"https://github.com/marksalpeter/token","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/marksalpeter/token","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marksalpeter%2Ftoken","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marksalpeter%2Ftoken/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marksalpeter%2Ftoken/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marksalpeter%2Ftoken/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marksalpeter","download_url":"https://codeload.github.com/marksalpeter/token/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marksalpeter%2Ftoken/sbom","scorecard":{"id":620458,"data":{"date":"2025-08-11","repo":{"name":"github.com/marksalpeter/token","commit":"c6c0ff322634a78dfb6232d8815825e1d6a5e250"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"Maintained","score":0,"reason":"0 commit(s) and 0 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":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"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":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":"Code-Review","score":0,"reason":"Found 0/23 approved changesets -- score normalized to 0","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":"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":"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"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":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"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 8 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"}},{"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"}}]},"last_synced_at":"2025-08-21T05:06:14.638Z","repository_id":8848106,"created_at":"2025-08-21T05:06:14.638Z","updated_at":"2025-08-21T05:06:14.638Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29157439,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T07:18:23.844Z","status":"ssl_error","status_checked_at":"2026-02-06T07:13:32.659Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["base62","encoder","go","golang","primary-key"],"created_at":"2026-02-06T09:45:14.070Z","updated_at":"2026-02-06T09:45:16.833Z","avatar_url":"https://github.com/marksalpeter.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Use v2 Instead \n**Warning: Breaking Changes**\n\nVersion 2 of this package is ready for production use. [You can find it here.](https://github.com/marksalpeter/token/blob/master/v2)\n\nThe order of the `Base62` characters have been changed in `v2` so that the `string` representation of the `Token` and the `int` representation of the token are in the same sort order. This is useful when scaling your app or using NoSQL solutions. Special thanks to [@sudhirj](https://github.com/sudhirj) for the suggestion.\n\n### References\n\nhttps://instagram-engineering.com/sharding-ids-at-instagram-1cf5a71e5a5c\n\nhttps://developer.twitter.com/en/docs/basics/twitter-ids.html\n\nhttps://github.com/ulid/spec\n\n---\n\n[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](http://godoc.org/github.com/marksalpeter/token)\n\nThis is a simple package for go that generates randomized base62 encoded tokens based on an integer. It's ideal for short url services or for any short, unique, randomized tokens you need to use throughout your app.\n\n## How it Works\n\n`Token` is an alias for `uint64`.\n\nThe `Token.Encode()` method returns a base62 encoded string based off of the uint64.\n\n`Token` implements the `encoding.TextMarshaler` and `encoding.TextUnmarshaler` interfaces to encode and decode to and from the base62 string representation of the `uint64`\n\nBasically, the outside world will always see the token as a base62 encoded string, but in your app you will always be able to use the token as a `uint64` for fast, indexed, unique, lookups in various databases.\n\n**IMPORTANT:** Remember to always check for collisions when adding randomized tokens to a database\n\n## Example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/marksalpeter/token\"\n)\n\ntype Model struct {\n    ID\ttoken.Token `json:\"id\"`\n}\n\nfunc main() {\n\t// create a new model\n\tmodel := Model {\n\t\tID:\ttoken.New(), // creates a new, random uint64 token\n\t}\n\tfmt.Println(model.ID)          // 2751173559858\n\tfmt.Println(model.ID.Encode()) // Mr1NSSu\n\n\t// encode the model as json\n\tmarshaled, err := json.Marshal(\u0026model)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(string(marshaled)) // {\"id\":\"Mr1NSSu\"}\n\n\t// decode the model\n\tvar unmarshaled Model\n\tif err := json.Unmarshal(marshaled, \u0026unmarshaled); err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(unmarshaled.ID)    // 2751173559858\n\n}\n```\n\n## Special Mentions\n\nSpecial thanks to [@einsteinx2](https://github.com/einsteinx2). The encode and decode functions are ported from a short url project of his and he graciously allowed me to publish them.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarksalpeter%2Ftoken","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarksalpeter%2Ftoken","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarksalpeter%2Ftoken/lists"}