{"id":13741143,"url":"https://github.com/ultd/base58-zig","last_synced_at":"2026-01-12T12:21:34.597Z","repository":{"id":165781080,"uuid":"641211448","full_name":"ultd/base58-zig","owner":"ultd","description":"A base58 encoder/decoder implementation in Zig","archived":false,"fork":false,"pushed_at":"2024-06-27T00:00:32.000Z","size":32,"stargazers_count":12,"open_issues_count":1,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-10T11:11:29.806Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Zig","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/ultd.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":"2023-05-16T02:32:43.000Z","updated_at":"2025-02-21T00:59:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"e1021a65-161a-463f-89cc-ccf4a4793137","html_url":"https://github.com/ultd/base58-zig","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ultd/base58-zig","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultd%2Fbase58-zig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultd%2Fbase58-zig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultd%2Fbase58-zig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultd%2Fbase58-zig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ultd","download_url":"https://codeload.github.com/ultd/base58-zig/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultd%2Fbase58-zig/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28338975,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T10:58:46.209Z","status":"ssl_error","status_checked_at":"2026-01-12T10:58:42.742Z","response_time":98,"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":[],"created_at":"2024-08-03T04:00:56.012Z","updated_at":"2026-01-12T12:21:34.580Z","avatar_url":"https://github.com/ultd.png","language":"Zig","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"\u003cbr/\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ch1\u003e\u0026nbsp;🌀 \u0026nbsp;\u0026nbsp;Base58-zig\u003c/h1\u003e\n    \u003cbr/\u003e\n    \u003cbr/\u003e\n  \u003ca href=\"https://github.com/ultd/base58-zig/releases/latest\"\u003e\u003cimg alt=\"Version\" src=\"https://img.shields.io/github/v/release/ultd/base58-zig?include_prereleases\u0026label=version\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/ultd/base58-zig/actions/workflows/test.yml\"\u003e\u003cimg alt=\"Build status\" src=\"https://img.shields.io/github/actions/workflow/status/ultd/base58-zig/test.yml?branch=main\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://ziglang.org/download\"\u003e\u003cimg alt=\"Zig\" src=\"https://img.shields.io/badge/zig-master-green.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/ultd/base58-zig/blob/main/LICENSE\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/badge/license-MIT-blue\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cbr/\u003e\n\n## Overview\n\n_base58-zig_ is encoder/decoder library written in Zig.\n\n## Installation\n\n### Manual\n\n1. Declare Base58-zig as a dependency in `build.zig.zon`:\n\n   ```diff\n   .{\n       .name = \"my-project\",\n       .version = \"1.0.0\",\n       .dependencies = .{\n   +       .@\"base58-zig\" = .{\n   +           .url = \"https://github.com/ultd/base58-zig/archive/\u003cCOMMIT\u003e.tar.gz\",\n   +       },\n       },\n   }\n   ```\n\n2. Expose Base58-zig as a module in `build.zig`:\n\n   ```diff\n   const std = @import(\"std\");\n\n   pub fn build(b: *std.Build) void {\n       const target = b.standardTargetOptions(.{});\n       const optimize = b.standardOptimizeOption(.{});\n\n   +   const opts = .{ .target = target, .optimize = optimize };\n   +   const base58_module = b.dependency(\"base58-zig\", opts).module(\"base58-zig\");\n\n       const exe = b.addExecutable(.{\n           .name = \"test\",\n           .root_source_file = .{ .path = \"src/main.zig\" },\n           .target = target,\n           .optimize = optimize,\n       });\n   +   exe.addModule(\"base58-zig\", base58_module);\n       exe.install();\n\n       ...\n   }\n   ```\n\n3. Obtain Base58-zig's package hash:\n\n   ```\n   $ zig build\n   my-project/build.zig.zon:6:20: error: url field is missing corresponding hash field\n           .url = \"https://github.com/ultd/base58-zig/archive/\u003cCOMMIT\u003e.tar.gz\",\n                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n   note: expected .hash = \"\u003cHASH\u003e\",\n   ```\n\n4. Update `build.zig.zon` with hash value:\n\n   ```diff\n   .{\n       .name = \"my-project\",\n       .version = \"1.0.0\",\n       .dependencies = .{\n           .@\"base58-zig\" = .{\n               .url = \"https://github.com/ultd/base58-zig/archive/\u003cCOMMIT\u003e.tar.gz\",\n   +           .hash = \"\u003cHASH\u003e\",\n           },\n       },\n   }\n   ```\n\n### API Reference\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eencodeAlloc\u003c/code\u003e - Encodes a `[]u8` into an alloc'ed base58 encoded string.\u003c/summary\u003e\n\n**Example**\n\n```zig\nconst std = @import(\"std\");\nconst base58 = @import(\"base58-zig\");\n\nconst allocator = std.heap.page_allocator;\n\nvar someBytes = [4]u8{ 10, 20, 30, 40 };\n\npub fn main() !void {\n    const encoder = base58.Encoder.init(.{});\n    var encodedStr = try encoder.encodeAlloc(allocator, \u0026someBytes);\n    defer allocator.free(encodedStr);\n    std.log.debug(\"encoded val: {s}\", .{encodedStr});\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eencode\u003c/code\u003e - Base58 Encodes a `[]u8` into an `dest` buffer passed and returns bytes written to buffer.\u003c/summary\u003e\n\n\u003cbr/\u003e\nThe `dest` buffer written to needs to be properly sized. Base58 encoding is a variable length encoder therefore you should allocate extra and then resize if needed afterwards. Below is an example.\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n**Example**\n\n```zig\nconst std = @import(\"std\");\nconst base58 = @import(\"base58-zig\");\n\nconst allocator = std.heap.page_allocator;\n\nvar someBytes = [4]u8{ 10, 20, 30, 40 };\n\npub fn main() !void {\n    const encoder = base58.Encoder.init(.{});\n\n    // allocate someBytes.len * 2 []u8\n    var dest = allocator.alloc(u8, someBytes.len * 2);\n\n    var size = try encoder.encode(\u0026someBytes, dest);\n    if(dest != size) {\n        dest = allocator.realloc(dest, size);\n    }\n\n    defer allocator.free(dest);\n    std.log.debug(\"encoded val: {s}\", .{dest});\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003edecodeAlloc\u003c/code\u003e - Decodes a base58 encoded string into a alloc'ed `[]u8` and returns it.\u003c/summary\u003e\n\n**Example**\n\n```zig\nconst std = @import(\"std\");\nconst base58 = @import(\"base58-zig\");\n\nconst allocator = std.heap.page_allocator;\n\nvar encodedStr: []const u8 = \"4rL4RCWHz3iNCdCaveD8KcHfV9YWGsqSHFPo7X2zBNwa\";\n\npub fn main() !void {\n    const decoder = base58.Decoder.init(.{});\n    var decodedBytes = try decoder.decodeAlloc(allocator, encodedStr);\n    defer allocator.free(decodedBytes);\n    std.log.debug(\"decoded bytes: {any}\", .{decodedBytes});\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003edecode\u003c/code\u003e - Decodes a base58 encoded string into `dest` buffer and returns number of bytes written.\u003c/summary\u003e\n\n\u003cbr/\u003e\nThe `dest` buffer written to needs to be properly sized. Base58 encoding is a variable length encoder therefore you should allocate same size buffer as encoded value and then resize, if needed, afterwards. Below is an example.\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n**Example**\n\n```zig\nconst std = @import(\"std\");\nconst base58 = @import(\"base58-zig\");\n\nconst allocator = std.heap.page_allocator;\n\nvar encodedStr: []const u8 = \"4rL4RCWHz3iNCdCaveD8KcHfV9YWGsqSHFPo7X2zBNwa\";\n\npub fn main() !void {\n    const decoder = base58.Decoder.init(.{});\n\n    // allocate 1 * encodedStr.len buffer\n    var dest = allocator.alloc(u8, encodedStr.len);\n\n    var size = try decoder.decode(encodedStr, dest);\n    if(dest.len != size){\n        dest = allocator.realloc(dest, size);\n    }\n\n    defer allocator.free(dest);\n    std.log.debug(\"decoded bytes: {any}\", .{dest});\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eAlphabet\u003c/code\u003e - create a custom alphabet set to pass to encoder/decoder`.\u003c/summary\u003e\n\n**Example**\n\n```zig\nconst std = @import(\"std\");\nconst base58 = @import(\"base58-zig\");\n\nconst allocator = std.heap.page_allocator;\n\nvar alpha = base58.Alphabet.new(.{\n.alphabet = [58]u8{...}. // custom alphabets\n});\n\npub fn main() !void {\n    const encoder = base58.Encoder.init(.{ alphabet = alpha });\n    var encodedStr = try encoder.encodeAlloc(allocator, \u0026someBytes);\n    defer allocator.free(encodedStr);\n    std.log.debug(\"encoded val: {s}\", .{encodedStr});\n}\n```\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fultd%2Fbase58-zig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fultd%2Fbase58-zig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fultd%2Fbase58-zig/lists"}