{"id":20388395,"url":"https://github.com/swift-libp2p/swift-multibase","last_synced_at":"2026-02-22T21:36:36.841Z","repository":{"id":122482420,"uuid":"487676620","full_name":"swift-libp2p/swift-multibase","owner":"swift-libp2p","description":"Self identifying base encodings using the Multibase spec","archived":false,"fork":false,"pushed_at":"2025-11-01T20:29:45.000Z","size":52,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-24T05:17:01.665Z","etag":null,"topics":["libp2p","multiformats"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/swift-libp2p.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-05-02T00:43:51.000Z","updated_at":"2025-11-24T11:18:53.000Z","dependencies_parsed_at":"2025-02-28T02:35:34.849Z","dependency_job_id":"fa9ff98a-96d9-4747-8c9e-dfc9804203ac","html_url":"https://github.com/swift-libp2p/swift-multibase","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/swift-libp2p/swift-multibase","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-libp2p%2Fswift-multibase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-libp2p%2Fswift-multibase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-libp2p%2Fswift-multibase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-libp2p%2Fswift-multibase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swift-libp2p","download_url":"https://codeload.github.com/swift-libp2p/swift-multibase/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-libp2p%2Fswift-multibase/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29728454,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T20:09:16.275Z","status":"ssl_error","status_checked_at":"2026-02-22T20:09:13.750Z","response_time":110,"last_error":"SSL_read: 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":["libp2p","multiformats"],"created_at":"2024-11-15T03:09:43.438Z","updated_at":"2026-02-22T21:36:36.835Z","avatar_url":"https://github.com/swift-libp2p.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multibase\n\n[![](https://img.shields.io/badge/made%20by-Breth-blue.svg?style=flat-square)](https://breth.app)\n[![](https://img.shields.io/badge/project-multiformats-blue.svg?style=flat-square)](https://github.com/multiformats/multiformats)\n[![Swift Package Manager compatible](https://img.shields.io/badge/SPM-compatible-blue.svg?style=flat-square)](https://github.com/apple/swift-package-manager)\n![Build \u0026 Test (macos and linux)](https://github.com/swift-libp2p/swift-multibase/actions/workflows/build+test.yml/badge.svg)\n\n\n\u003e Self identifying base encodings using the Multibase spec\n\n## Table of Contents\n\n- [Overview](#overview)\n- [Install](#install)\n- [Usage](#usage)\n  - [Example](#example)\n  - [API](#api)\n- [Contributing](#contributing)\n- [Credits](#credits)\n- [License](#license)\n\n## Overview\nMultibase is a protocol for disambiguating the encoding of base-encoded (e.g.,\nbase32, base36, base64, base58, etc.) binary appearing in text.\n\nWhen text is encoded as bytes, we can usually use a one-size-fits-all encoding\n(UTF-8) because we're always encoding to the same set of 256 bytes (+/- the NUL\nbyte). When that doesn't work, usually for historical or performance reasons, we\ncan usually infer the encoding from the context.\n\nHowever, when bytes are encoded as text (using a base encoding), the base choice\nof base encoding is often restricted by the context. Worse, these restrictions\ncan change based on where the data appears in the text. In some cases, we can\nonly use `[a-z0-9]`. In others, we can use a larger set of characters but need a\ncompact encoding. This has lead to a large set of \"base encodings\", one for\nevery use-case. Unlike when encoding text to bytes, we can't just standardize\naround a single base encoding because there is no optimal encoding for all\ncases.\n\nUnfortunately, it's not always clear *what* base encoding is used; that's where\nmultibase comes in. It answers the question:\n\n\u003e Given data d encoded into text s, what base is it encoded with?\n\n#### Heads up ‼️\n- This library was built quickly and dirty as part of a larger project.\n- This library hasn't been extensively tested! \n- I wouldn't use this in production until you've vetted it yourself! \n\n#### For more details see \n- [Multiformats / Mulitbase Spec](https://github.com/multiformats/multibase)\n\n\n## Install\n\nInclude the following dependency in your Package.swift file\n```Swift\nlet package = Package(\n    ...\n    dependencies: [\n        ...\n        .package(url: \"https://github.com/swift-libp2p/swift-multibase.git\", .upToNextMajor(from: \"0.0.1\"))\n    ],\n    ...\n    targets: [\n        .target(\n            ...\n            dependencies: [\n                ...\n                .product(name: \"Multibase\", package: \"swift-multibase\"),\n            ]),\n    ]\n    ...\n)\n```\n\n## Usage\n\n### Example\n\n```Swift\nimport Multibase\n\n/// The Multibase format is:\n/// \u003cbase-encoding-character\u003e\u003cbase-encoded-data\u003e\n/// Where `\u003cbase-encoding-character\u003e` is used according to the multibase table.\n\n// To Encode a human readable string into a certain base encoding...\n\"Decentralize Everything!!\".encode(as: .base8) // -\u003e \"72106254331267164344605543227514510062566312711713506415133463441102\" -- Note the '7' multibase prefix tag\n\"Decentralize Everything!!\".encode(as: .base64) // -\u003e \"mRGVjZW50cmFsaXplIGV2ZXJ5dGhpbmchIQ\" -- Note the 'm' multibase prefix tag\n\n// To Decode a Multibase encoded string (one that has the proper base prefix prepended)...\ntry BaseEncoding.decodeIntoString(\"72106254331267164344605543227514510062566312711713506415133463441102\") // -\u003e (base: .base8, string: \"Decentralize Everything!!\")\ntry BaseEncoding.decodeIntoString(\"mRGVjZW50cmFsaXplIGV2ZXJ5dGhpbmchIQ\") // -\u003e (base: .base64, string: \"Decentralize Everything!!\")\n\n/// String/Data/[UInt8] extensions (NOTE: all extensions default to no Multibase prefix!)\n\"Hello World\".data(using: .utf8)!.asString(base: .base16)                              // -\u003e  48656c6c6f20576f726c64 \n\"Hello World\".data(using: .utf8)!.asString(base: .base16, withMultibasePrefix: true)   // -\u003e f48656c6c6f20576f726c64\n\n```\n\n### API\n```Swift\n\n/// BaseEncoding Enum\nlet multibase = try! BaseEncoding.decodeIntoString(\"t8him6pbeehp62r39f9ii0pbmclp7it38d5n6e891\")\nmultibase2.base   // -\u003e .base32HexPad\nmultibase2.string // -\u003e \"Decentralize everything!!\"\n\n\n/// String Extensions\nString(decoding:String, as:BaseEncoding, using:String.Encoding = .utf8) throws\nString.baseEncoding -\u003e BaseEncoding\nString.encode(as: BaseEncoding, using:String.Encoding = .ascii) -\u003e String\n\n\n/// Data Extensions\nData.init(decoding:String, as:BaseEncoding) throws\nData.asString(base:BaseEncoding, withMultibasePrefix:Bool = false) -\u003e String\n\n\n/// Array\u003cUInt8\u003e Extensions\nArray\u003cUInt8\u003e(decoding:String, as:BaseEncoding) throws\nArray\u003cUInt8\u003e.asString(base:BaseEncoding, withMultibasePrefix:Bool = false) -\u003e String\n\n```\n\n## Contributing\n\nContributions are welcomed! This code is very much a proof of concept. I can guarantee you there's a better / safer way to accomplish the same results. Any suggestions, improvements, or even just critques, are welcome! \n\nLet's make this code better together! 🤝\n\n## Credits\n\n- [Multiformat / Multibase Spec](https://github.com/multiformats/multibase)\n\n\n## License\n\n[MIT](LICENSE) © 2022 Breth Inc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswift-libp2p%2Fswift-multibase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswift-libp2p%2Fswift-multibase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswift-libp2p%2Fswift-multibase/lists"}