https://github.com/atprotokit/multiformatskit
A Swift implementation of the Multiformats spec, including Multibase, Multicodec, Multihash, and CID.
https://github.com/atprotokit/multiformatskit
cid ipfs ipld multibase multicodec multiformats multihash
Last synced: 2 months ago
JSON representation
A Swift implementation of the Multiformats spec, including Multibase, Multicodec, Multihash, and CID.
- Host: GitHub
- URL: https://github.com/atprotokit/multiformatskit
- Owner: ATProtoKit
- License: apache-2.0
- Created: 2025-03-25T20:20:05.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2025-03-26T00:05:25.000Z (2 months ago)
- Last Synced: 2025-03-26T00:40:28.495Z (2 months ago)
- Topics: cid, ipfs, ipld, multibase, multicodec, multiformats, multihash
- Language: Swift
- Homepage:
- Size: 323 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
![]()
MultiformatsKit
[](https://github.com/ATProtoKit/MultiformatsKit)
[](https://bsky.app/profile/cjrriley.com)
[](https://github.com/sponsors/MasterJ93)**MultiformatsKit** is a native Swift implementation of the [Multiformats](https://multiformats.io) protocol suite — including [Multibase](https://github.com/multiformats/multibase), [Multicodec](https://github.com/multiformats/multicodec), [Multihash](https://github.com/multiformats/multihash), and [CID](https://github.com/multiformats/cid).
This package enables content-addressing, self-describing data structures, and CID generation — all with `Sendable`-safe Swift code.
## Quick Example
```swift
import MultiformatsKitTask {
do {
let cid = try await CID(content: "Hello, World!")// CIDv1 encoded with base32
print("CIDv1:", cid.encode())// Decode back into a CID
let decoded = try await CID.decode(from: cid.encode())
print("Decoded multihash:", decoded.multihash)
} catch {
print("Error:", error)
}
}
```## Features
- Fully `Sendable`-safe and concurrency-ready.
- Supports CIDv0 and CIDv1 (including `dag-pb` with `sha2-256`).
- Multibase encoding/decoding with support for:
- Base2, Base8, Base10, Base16
- Base58 (BTC, Flickr)
- Base32 (lower/upper, padded/unpadded, hex variants)
- Multicodec registration.
- Multihash support with plug-and-play hashing algorithms.
- RFC 4648 compliance for fixed-bit encoding.
- Varint encoding/decoding.
- Written entirely in Swift — no C or unsafe code.## Installation
You can use the Swift Package Manager to download and import the library into your project:
```swift
dependencies: [
.package(url: "https://github.com/ATProtoKit/MultiformatsKit.git", from: "0.1.0")
]
```Then under `targets`:
```swift
targets: [
.target(
// name: "[name of target]",
dependencies: [
.product(name: "MultiformatsKit", package: "multiformatskit")
]
)
]
```## Requirements
To use MultiformatsKit in your apps, your app should target the specific version numbers:
- **iOS** and **iPadOS** 14 or later.
- **macOS** 12 or later.
- **tvOS** 14 or later.
- **visionOS** 1 or later.
- **watchOS** 9 or later.For Linux, you need to use Swift 6.0 or later. On Linux, the minimum requirements include:
- **Amazon Linux** 2
- **Debian** 12
- **Fedora** 39
- **Red Hat UBI** 9
- **Ubuntu** 20.04You can also use this project for any programs you make using Swift and running on **Docker**.
> [!WARNING]
> As of right now, Windows support is theoretically possible, but not has not been tested to work. Contributions and feedback on making it fully compatible for Windows and Windows Server are welcomed.## Submitting Contributions and Feedback
While this project will change significantly, feedback, issues, and contributions are highly welcomed and encouraged. If you'd like to contribute to this project, please be sure to read both the [API Guidelines](https://github.com/ATProtoKit/MultiformatsKit/blob/main/API_GUIDELINES.md) as well as the [Contributor Guidelines](https://github.com/MasterJ93/ATProtoKit/blob/main/CONTRIBUTING.md) before submitting a pull request. Any issues (such as bug reports or feedback) can be submitted in the [Issues](https://github.com/ATProtoKit/MultiformatsKit/issues) tab. Finally, if there are any security vulnerabilities, please read [SECURITY.md](https://github.com/ATProtoKit/MultiformatsKit/blob/main/SECURITY.md) for how to report it.If you have any questions, you can ask me on Bluesky ([@cjrriley.com](https://bsky.app/profile/cjrriley.com)). And while you're at it, give me a follow! I'm also active on the [Bluesky API Touchers](https://discord.gg/3srmDsHSZJ) Discord server.
## License
This Swift package is using the Apache 2.0 License. Please view [LICENSE.md](https://github.com/ATProtoKit/MultiformatsKit/blob/main/LICENSE.md) for more details.