{"id":37152523,"url":"https://github.com/juranki/branca","last_synced_at":"2026-01-14T18:00:33.169Z","repository":{"id":66943496,"uuid":"157105860","full_name":"juranki/branca","owner":"juranki","description":"Branca token encoding/decoding","archived":false,"fork":false,"pushed_at":"2018-12-10T18:23:49.000Z","size":38,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-14T14:43:47.458Z","etag":null,"topics":["branca","golang","jwt"],"latest_commit_sha":null,"homepage":"","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/juranki.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":"2018-11-11T17:58:56.000Z","updated_at":"2020-02-20T19:40:32.000Z","dependencies_parsed_at":"2023-05-15T08:00:21.789Z","dependency_job_id":null,"html_url":"https://github.com/juranki/branca","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/juranki/branca","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juranki%2Fbranca","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juranki%2Fbranca/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juranki%2Fbranca/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juranki%2Fbranca/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juranki","download_url":"https://codeload.github.com/juranki/branca/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juranki%2Fbranca/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28429321,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T16:38:47.836Z","status":"ssl_error","status_checked_at":"2026-01-14T16:34:59.695Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["branca","golang","jwt"],"created_at":"2026-01-14T18:00:21.028Z","updated_at":"2026-01-14T18:00:33.144Z","avatar_url":"https://github.com/juranki.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# branca\n\n[![Build Status](https://travis-ci.org/juranki/branca.svg?branch=master)](https://travis-ci.org/juranki/branca)\n[![GoDoc](https://godoc.org/github.com/juranki/branca?status.svg)](https://godoc.org/github.com/juranki/branca)\n\nImplements encoding and decoding for [branca tokens](https://github.com/tuupola/branca-spec).\n\n## Install\n\n```\ngo get -u github.com/juranki/branca\n```\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/juranki/branca\"\n)\n\nfunc main() {\n\t// The encryption key must be exactly 32 bytes.\n\tcodec, err := branca.New(\"01234567890123456789012345678901\")\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\n\ttoken, err := codec.Encode([]byte(\"payload\"))\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\tfmt.Printf(\"Encrypted token: %s\\n\", token)\n\n\tpayload, createTime, err := codec.Decode(token)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Printf(\"Payload: %s\\n\", payload)\n\tfmt.Printf(\"Creation time: %s\\n\", createTime)\n}\n\n```\n\nOutput:\n```\nEncrypted token: Q2BbddzrYDzFTQnBsdILsj5CDU9JAp3VDKfe3CjnLciSIIbjNM7dCealKpfmuXzYqM6wsh\nPayload: payload\nCreation time: 2018-11-15 00:47:03 +0200 EET\n```\n\n## Using base64URL encoding instead of base62\n\n\nTo use base64URL encoding instead of base62 import `github.com/juranki/branca/encoding/base64url`\nand change following line of the previous example\n```go\ncodec, err := branca.New(\"01234567890123456789012345678901\")\n```\nto\n```go\ncodec, err := branca.NewWithEncoding(\"01234567890123456789012345678901\", base64url.New())\n```\n\n\nOutput:\n```\nEncrypted token: ulvspfVaU_BlhqCk-G-XDwG6CLfZPoKGbcJpRh_B97qawKqYZYWtNsFmkL7wttVxZDWV-A==\nPayload: payload\nCreation time: 2018-11-15 00:47:17 +0200 EET\n```\n\nBase64 is significantly faster than base62, but it doesn't comply with branca spec. Here \nare benchmark results using different string encoders:\n\n```\nBenchmarkEncode20Bytes-8               \t  100000\t     15206 ns/op\t     784 B/op\t      13 allocs/op\nBenchmarkEncode50Bytes-8               \t   50000\t     27561 ns/op\t     896 B/op\t      13 allocs/op\nBenchmarkEncode100Bytes-8              \t   30000\t     57926 ns/op\t    1248 B/op\t      13 allocs/op\nBenchmarkDecode20Bytes-8               \t  300000\t      4070 ns/op\t     688 B/op\t      12 allocs/op\nBenchmarkDecode50Bytes-8               \t  200000\t      5953 ns/op\t    1152 B/op\t      15 allocs/op\nBenchmarkDecode100Bytes-8              \t  200000\t      9393 ns/op\t    1824 B/op\t      18 allocs/op\n\nBenchmarkEncode20BytesBasex-8          \t   30000\t     58547 ns/op\t    2496 B/op\t      12 allocs/op\nBenchmarkEncode50BytesBasex-8          \t   10000\t    117016 ns/op\t    2544 B/op\t      12 allocs/op\nBenchmarkEncode100BytesBasex-8         \t    5000\t    267366 ns/op\t    5024 B/op\t      14 allocs/op\nBenchmarkDecode20BytesBasex-8          \t  300000\t      4814 ns/op\t     640 B/op\t       8 allocs/op\nBenchmarkDecode50BytesBasex-8          \t  200000\t      8787 ns/op\t     832 B/op\t       8 allocs/op\nBenchmarkDecode100BytesBasex-8         \t  100000\t     17546 ns/op\t    1520 B/op\t       9 allocs/op\n\nBenchmarkEncode20BytesBase64-8         \t 1000000\t      1329 ns/op\t     304 B/op\t       4 allocs/op\nBenchmarkEncode50BytesBase64-8         \t 1000000\t      1441 ns/op\t     384 B/op\t       4 allocs/op\nBenchmarkEncode100BytesBase64-8        \t 1000000\t      1707 ns/op\t     608 B/op\t       4 allocs/op\nBenchmarkDecode20BytesBase64-8         \t 2000000\t       691 ns/op\t     208 B/op\t       3 allocs/op\nBenchmarkDecode50BytesBase64-8         \t 2000000\t       813 ns/op\t     288 B/op\t       3 allocs/op\nBenchmarkDecode100BytesBase64-8        \t 1000000\t      1042 ns/op\t     480 B/op\t       3 allocs/op\n\nBenchmarkEncode20BytesHashi-8          \t  300000\t      4559 ns/op\t    1120 B/op\t      15 allocs/op\nBenchmarkEncode50BytesHashi-8          \t  300000\t      5583 ns/op\t    1296 B/op\t      15 allocs/op\nBenchmarkEncode100BytesHashi-8         \t  200000\t      8559 ns/op\t    2322 B/op\t      19 allocs/op\nBenchmarkDecode20BytesHashi-8          \t 1000000\t      1553 ns/op\t     272 B/op\t       5 allocs/op\nBenchmarkDecode50BytesHashi-8          \t 1000000\t      2046 ns/op\t     448 B/op\t       6 allocs/op\nBenchmarkDecode100BytesHashi-8         \t  500000\t      2938 ns/op\t     720 B/op\t       7 allocs/op\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuranki%2Fbranca","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuranki%2Fbranca","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuranki%2Fbranca/lists"}