Swiftpack.co - alephao/swift-rlp as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by alephao.
alephao/swift-rlp v0.0.6
Recursive Length Prefix encoding written in Swift
⭐️ 23
🕓 4 weeks ago
iOS macOS
.package(url: "https://github.com/alephao/swift-rlp.git", from: "v0.0.6")


Swift 5.9.2 Version

This is a simple, pure Swift implementation of Recursive Length Prefix Encoding, a serialisation method for encoding arbitrarily structured binary data (byte arrays).

RLP Encoding is used in Ethereum. You can read more about it here:

Library Usage

SwiftRLP is available through Swift Package Manager.

Adding SwiftRLP as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
  .package(url: "https://github.com/alephao/swift-rlp.git", from: "0.0.6")
targets: [
      name: "MyTarget",
      dependencies: [
        .product(name: "SwiftRLP", package: "swift-rlp")


import SwiftRLP

let encoder = RLPEncoder()

// String Encoding
try encoder.encode(.string("dog"))
try encoder.encode(string: "dog")

// Array Encoding
try encoder.encode(.array(["d", "o", "g"]))


import SwiftRLP

let encodedData = try RLPEncoder().encode(string: "dog")

let decoder = RLPDecoder()
try decoder.decode(from: encodedData) // RLPValue.string("dog")


Currently, the CLI is only available via source code. To use it, clone this repo and run:


$ swift run cli encode dog
> 0x83646F67


$ swift run cli decode 0x83646F67
> string("dog")


SwiftRLP is released under an MIT license. See LICENSE for more information.


Stars: 23
Last commit: 4 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

4 weeks ago

Complete Remake

  • Instead of using the RLP.encode static func, now you need to c reate an RLPEncoder or RLPDecoder to encode/decode.
  • Added a cli utility

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics