Base58Swift

2.1.15

A pure swift implementation of base58 string encoding and decoding
heckj/Base58Swift

What's New

2.1.15

2024-05-23T15:52:12Z

What's Changed

  • Adding patch for strings with leading 1s and test in #1

New Contributors

  • @heckj made their first contribution in #1

Full Changelog: https://github.com/heckj/Base58Swift/commits/2.1.15

Base58Swift

This is a fork of the Base58Swift project. The upstream project had a longstanding issue with a pull request pending to resolve it, but with no action for months. Based on that, I'm assuming the project is at least in hibernation.

This project applies the fix to host a solution.

Base58Swift is a Swift library that implements Base58 / Base58Check encodings for cryptocurrencies. It is based off of go-base-58 with some added functions.

Installation

Swift Package Manager

Add the following to the dependencies section of your Package.swift file:

.package(url: "https://github.com/heckj/Base58Swift.git", from: "2.1.0")

Usage

Base58Swift provides a static utility class, Base58, which provides encoding and decoding functions.

To encode / decode in Base58:

let bytes: [UInt8] = [255, 254, 253, 252]

let encodedString = Base58.encode(bytes)!
let decodedBytes = Base58.decode(encodedString)!

print(encodedString) // 7YXVWT
print(decodedBytes)  // [255, 254, 253, 252]

To encode / decode in Base58Check:

let bytes: [UInt8] = [255, 254, 253, 252]

let encodedString = Base58.base58CheckEncode(bytes)!
let decodedBytes = Base58.base58CheckDecode(encodedString)!

print(encodedString) // jpUz5f99p1R
print(decodedBytes)  // [255, 254, 253, 252]

License

MIT

Description

  • Swift Tools 5.0.0
View More Packages from this Author

Dependencies

Last updated: Mon Nov 11 2024 21:55:12 GMT-1000 (Hawaii-Aleutian Standard Time)