{"id":22166680,"url":"https://github.com/alextanhongpin/base62","last_synced_at":"2025-03-24T16:32:11.044Z","repository":{"id":57634023,"uuid":"151738505","full_name":"alextanhongpin/base62","owner":"alextanhongpin","description":"A simple base62 url shortener implementation","archived":false,"fork":false,"pushed_at":"2018-11-12T04:35:45.000Z","size":1779,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-29T21:54:24.433Z","etag":null,"topics":["base62","go","golang","url-shortener"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alextanhongpin.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":"2018-10-05T15:06:42.000Z","updated_at":"2018-11-12T04:35:46.000Z","dependencies_parsed_at":"2022-08-31T16:31:07.247Z","dependency_job_id":null,"html_url":"https://github.com/alextanhongpin/base62","commit_stats":null,"previous_names":["alextanhongpin/go-base62"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alextanhongpin%2Fbase62","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alextanhongpin%2Fbase62/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alextanhongpin%2Fbase62/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alextanhongpin%2Fbase62/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alextanhongpin","download_url":"https://codeload.github.com/alextanhongpin/base62/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245308645,"owners_count":20594281,"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":["base62","go","golang","url-shortener"],"created_at":"2024-12-02T05:20:37.163Z","updated_at":"2025-03-24T16:32:11.016Z","avatar_url":"https://github.com/alextanhongpin.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-base62\n\n[![](https://godoc.org/github.com/alextanhongpin/base62?status.svg)](http://godoc.org/github.com/alextanhongpin/base62)\n\nBase62 encoder/decoder with golang. Uses the variant `[A-Za-z0-9]`, but can be initialized with custom variant. The test cases covered the variant mentioned previously.\n\n## Installation\n\n```bash\n$ go get github.com/alextanhongpin/base62\n```\n\n## Usage\n\nEncode/Decode:\n```go\nimport base62 \"github.com/alextanhongpin/base62\"\n\nfunc main() {\n  fmt.Println(base62.Decode(\"golang\")) // Outputs: 30847375997\n  fmt.Println(base62.Encode(30847375997)) // Outputs: \"golang\"\n}\n```\n\nFactory:\n\n```go\nimport base62 \"github.com/alextanhongpin/base62\"\n\nfunc main() {\n  b62 := base62.New(base62.DEFAULT_CHARS) // Or use your own variant\n  fmt.Println(b62.Decode(\"golang\")) // Outputs: 30847375997\n  fmt.Println(b62.Encode(30847375997)) // Outputs: \"golang\"\n}\n```\n\n## Test Table\n\nTo test the encoding/decoding, we use the [NATO Phonetic Alphabets](https://en.wikipedia.org/wiki/NATO_phonetic_alphabet). If the encoded values matches the decoded values, the test passes. There's a `quickcheck` test too to capture unexpected input.\n\n| Text | Decoded |\n|------|---------|\n| Alfa | 386411 |\n| Bravo | 40145909 |\n| Charlie | 201958818817 |\n| Delta | 66642463 |\n| Echo | 1305265 |\n| Foxtrot | 379112811228 |\n| Golf | 1828288 |\n| Hotel | 128160920 |\n| India | 142637661 |\n| Juliett | 611630563254 |\n| Kilo | 2758545 |\n| Lima | 2996921 |\n| Mike | 3235129 |\n| November | 51675855992598 |\n| Oscar | 232482994 |\n| Papa | 3919667 |\n| Quebec | 16276243687 |\n| Romeo | 275897375 |\n| Sierra | 17931255627 |\n| Tango | 302117423 |\n| Uniform | 1229975219171 |\n| Victor | 20679184986 |\n| Whiskey | 1338081975441 |\n| Xray | 5890733 |\n| Yankee | 23311959173 |\n| Zulu | 6379599 |\n\n## Performance test\n\nIt's fast. Period. \n\n```\n$ go test -bench=. -benchmem -memprofile mem.out -cpuprofile cpu.out\n```\n\nOutput:\n\n```\ngoos: darwin\ngoarch: amd64\npkg: github.com/alextanhongpin/base62\nBenchmarkEncode-4   \t10000000\t       200 ns/op\t      64 B/op\t       2 allocs/op\nPASS\nok  \tgithub.com/alextanhongpin/base62\t2.378s\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falextanhongpin%2Fbase62","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falextanhongpin%2Fbase62","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falextanhongpin%2Fbase62/lists"}