https://github.com/keefertaylor/base58swift
A pure swift implementation of base58 string encoding and decoding
https://github.com/keefertaylor/base58swift
base58 cryptocurrency swift
Last synced: 5 months ago
JSON representation
A pure swift implementation of base58 string encoding and decoding
- Host: GitHub
- URL: https://github.com/keefertaylor/base58swift
- Owner: keefertaylor
- License: mit
- Created: 2019-02-13T21:19:13.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-23T15:40:15.000Z (over 1 year ago)
- Last Synced: 2025-05-07T07:48:48.097Z (5 months ago)
- Topics: base58, cryptocurrency, swift
- Language: Swift
- Size: 712 KB
- Stars: 13
- Watchers: 1
- Forks: 13
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Base58Swift
[](https://travis-ci.org/keefertaylor/Base58Swift)
[](https://codecov.io/gh/keefertaylor/Base58Swift)
[](https://github.com/Carthage/Carthage)
[](http://cocoapods.org/pods/Base58Swift)
[](http://cocoapods.org/pods/Base58Swift)Base58Swift is a Swift library that implements Base58 / Base58Check encodings for cryptocurrencies. It is based off of [go-base-58](https://github.com/jbenet/go-base58) with some added functions.
## Installation
### CocoaPods
Base58Swift supports installation via CocoaPods. You can depend on Base58Swift by adding the following to your Podfile:```
pod "Base58Swift"
```### Carthage
If you use [Carthage](https://github.com/Carthage/Carthage) to manage your dependencies, simply add
Base58Swift to your `Cartfile`:```
github "keefertaylor/Base58Swift"
```If you use Carthage to build your dependencies, make sure you have added `BigInt.framework` and `SipHash.framework`, to the "_Linked Frameworks and Libraries_" section of your target, and have included them in your Carthage framework copying build phase.
### Swift Package Manager
Add the following to the `dependencies` section of your `Package.swift` file:
```swift
.package(url: "https://github.com/keefertaylor/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:
```swift
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:
```swift
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]
```## Contributing
Pull requests are welcome.
To get set up:
```shell
$ brew install xcodegen # if you don't already have it
$ xcodegen generate # Generate an XCode project from Project.yml
$ open Base58Swift.xcodeproj
```## License
MIT