{"id":28865528,"url":"https://github.com/busyloop/suzuri","last_synced_at":"2025-10-30T23:31:43.925Z","repository":{"id":43383726,"uuid":"260440455","full_name":"busyloop/suzuri","owner":"busyloop","description":"Authenticated and encrypted tokens","archived":false,"fork":false,"pushed_at":"2023-01-13T02:11:35.000Z","size":59,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-06T00:05:08.795Z","etag":null,"topics":["crypto","crystal","security"],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/busyloop.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":"2020-05-01T11:12:58.000Z","updated_at":"2023-01-10T23:23:39.000Z","dependencies_parsed_at":"2023-02-09T14:16:29.295Z","dependency_job_id":null,"html_url":"https://github.com/busyloop/suzuri","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/busyloop/suzuri","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/busyloop%2Fsuzuri","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/busyloop%2Fsuzuri/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/busyloop%2Fsuzuri/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/busyloop%2Fsuzuri/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/busyloop","download_url":"https://codeload.github.com/busyloop/suzuri/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/busyloop%2Fsuzuri/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260924539,"owners_count":23083525,"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":["crypto","crystal","security"],"created_at":"2025-06-20T10:13:36.765Z","updated_at":"2025-10-30T23:31:43.858Z","avatar_url":"https://github.com/busyloop.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Suzuri\n[![Build](https://github.com/busyloop/suzuri/workflows/Build/badge.svg)](https://github.com/busyloop/suzuri/actions?query=workflow%3ABuild+branch%3Amaster) [![GitHub](https://img.shields.io/github/license/busyloop/suzuri)](https://en.wikipedia.org/wiki/MIT_License) [![GitHub release](https://img.shields.io/github/release/busyloop/suzuri.svg)](https://github.com/busyloop/suzuri/releases)\n\nSuzuri is a secure and easy to use token format that employs  \n[XChaCha20-Poly1305 AEAD](https://doc.libsodium.org/secret-key_cryptography/aead/chacha20-poly1305/xchacha20-poly1305_construction) symmetric encryption to create  \nauthenticated, encrypted, tamperproof tokens.  \n\nIt compresses and encrypts an arbitrary sequence of bytes,  \nthen encodes the result to url-safe Base64.\n\nSuzuri tokens can be used as a secure alternative to JWT  \nor for any type of general purpose message passing.\n\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n   ```yaml\n   dependencies:\n     suzuri:\n       github: busyloop/suzuri\n   ```\n\n2. Run `shards install`\n\n## Documentation\n\n* [API Documentation](https://busyloop.github.io/suzuri/Suzuri.html)\n\n\n## Usage\n\n```crystal\nrequire \"suzuri\"\n\nTEST_KEY = \"TheKeyLengthMustBeThirtyTwoBytes\"\n\n## Encode\ntoken_str = Suzuri.encode(\"hello world\", TEST_KEY) # =\u003e \"(url-safe base64)\"\n\n## Decode\ntoken = Suzuri.decode(token_str, TEST_KEY)   # =\u003e Suzuri::Token\ntoken.to_s                                   # =\u003e \"hello world\"\ntoken.timestamp                              # =\u003e 2020-01-01 01:23:45.0 UTC\n\n## Decode with a TTL constraint\ntoken_str = Suzuri.encode(\"hello world\", TEST_KEY) # =\u003e \"(url-safe base64)\"\nsleep 5\nSuzuri.decode(token_str, TEST_KEY, 2.seconds) # =\u003e Suzuri::Error::TokenExpired\n```\n\n## Usage (with [JSON::Serializable](https://crystal-lang.org/api/0.34.0/JSON/Serializable.html))\n\n```crystal\nrequire \"suzuri/json_serializable\"\n\nTEST_KEY = \"TheKeyLengthMustBeThirtyTwoBytes\"\n\nclass Person\n   include JSON::Serializable\n\n   @[JSON::Field]\n   property name : String\n\n   def initialize(@name)\n   end\nend\n\nbob = Person.new(name: \"bob\")\ntoken_str = bob.to_suzuri(TEST_KEY)\n\nbob2 = Person.from_suzuri(token_str, TEST_KEY)\nbob2.name # =\u003e \"bob\"\n```\n\n\n## Compression\n\nBy default Suzuri applies zstd compression before encryption when the  \npayload is larger than 512 bytes. The compression threshold and level  \ncan be chosen at runtime.\n\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/busyloop/suzuri/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Credits\n\nSuzuri is inspired by (but not compatible to) [Branca](https://github.com/tuupola/branca-spec/)-tokens. The underlying encryption is identical.  \nSuzuri adds compression support and serializes to url-safe Base64 instead of Base62.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbusyloop%2Fsuzuri","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbusyloop%2Fsuzuri","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbusyloop%2Fsuzuri/lists"}