Base58Swift
Base58Swift 是一个 Swift 库,实现了加密货币的 Base58 / Base58Check 编码。它基于 go-base-58 并增加了一些功能。
捐款可以帮助我找到时间来改进 Base58Swift。如果您觉得这个库很有用,请考虑捐款以支持持续的开发。
货币 | 地址 |
---|---|
Tezos | tz1SNXT8yZCwTss2YcoFi3qbXvTZiCojx833 |
Bitcoin | 1CdPoF9cvw3YEiuRCHxdsGpvb5tSUYBBo |
Bitcoin Cash | qqpr9are9gzs5r0q7hy3gdehj3w074pyqsrhpdmxg6 |
安装
CocoaPods
Base58Swift 支持通过 CocoaPods 安装。您可以在 Podfile 中添加以下内容来依赖 Base58Swift
pod "Base58Swift"
Carthage
如果您使用 Carthage 来管理依赖项,只需将 Base58Swift 添加到您的 Cartfile
github "keefertaylor/Base58Swift"
如果您使用 Carthage 构建依赖项,请确保您已将 BigInt.framework
和 SipHash.framework
添加到目标中的 "链接框架和库" 部分,并在 Carthage 框架复制构建阶段中包含它们。
Swift包管理器
将以下内容添加到您的Package.swift
文件中的dependencies
部分
.package(url: "https://github.com/keefertaylor/Base58Swift.git", from: "2.1.0")
使用方法
Base58Swift提供了一个静态实用类Base58
,该类提供编码和解码函数。
在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]
在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]
贡献
欢迎Pull requests。
进行设置
$ brew install xcodegen # if you don't already have it
$ xcodegen generate # Generate an XCode project from Project.yml
$ open Base58Swift.xcodeproj
许可
MIT