https://github.com/alja7dali/swift-base58
A base58 implementation in swift
https://github.com/alja7dali/swift-base58
base58 bitcoin btc decoding encoding swift
Last synced: 7 months ago
JSON representation
A base58 implementation in swift
- Host: GitHub
- URL: https://github.com/alja7dali/swift-base58
- Owner: Alja7dali
- License: mit
- Created: 2021-03-31T16:52:24.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-31T17:47:30.000Z (over 4 years ago)
- Last Synced: 2025-01-16T19:51:20.362Z (9 months ago)
- Topics: base58, bitcoin, btc, decoding, encoding, swift
- Language: Swift
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
###### This is an implementation of [Base58](https://en.wikipedia.org/wiki/Base58) `encode`/`decode` `check`/`uncheck` algorithm.
#### Example:
```swift
import Base58/// Encoding to Base58
/// 1. convert string to bytes (utf8 format)
let bytes = "Hello, World!".makeBytes()
/// 2. encode bytes using base58 algorithm
let encodedBytes = Base58.encode(bytes)
/// 3. converting bytes back to string
let encodedString = try String(encoded) // "72k1xXWG59fYdzSNoA"/// Decoding from Base58
/// 1. convert string to bytes (utf8 format)
let bytes = "72k1xXWG59fYdzSNoA".makeBytes()
/// 2. decode bytes using base58 algorithm
let decodedBytes = try Base58.decode(bytes)
/// 3. converting bytes back to string
let decodedString = try String(encoded) // "Hello, World!"/// Encoding to Base58Check
/// 1. convert string to bytes (utf8 format)
let bytes = "Hello, World!".makeBytes()
/// 2. encode bytes using base58Check algorithm
let encodedBytes = Base58.check(bytes)
/// 3. converting bytes back to string
let encodedString = try String(encoded) // "gTazoqFvnegwaKM8v2MZsVw"/// Decoding from Base58Check
/// 1. convert string to bytes (utf8 format)
let bytes = "gTazoqFvnegwaKM8v2MZsVw".makeBytes()
/// 2. decode bytes using base58Check algorithm
let decodedBytes = try Base58.uncheck(bytes)
/// 3. converting bytes back to string
let decodedString = try String(encoded) // "Hello, World!"
```#### Importing Base58:
To include `Base58` in your project, you need to add the following to the `dependencies` attribute defined in your `Package.swift` file.
```swift
dependencies: [
.package(url: "https://github.com/alja7dali/swift-base58.git", from: "1.0.0")
]
```