https://github.com/mr-tron/base58
Fast implementation of base58 encoding on golang.
https://github.com/mr-tron/base58
base58 encoding fast golang
Last synced: 6 months ago
JSON representation
Fast implementation of base58 encoding on golang.
- Host: GitHub
- URL: https://github.com/mr-tron/base58
- Owner: mr-tron
- License: mit
- Created: 2017-03-14T12:21:10.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-05-31T14:53:28.000Z (over 5 years ago)
- Last Synced: 2025-04-12T14:18:43.030Z (6 months ago)
- Topics: base58, encoding, fast, golang
- Language: Go
- Size: 67.4 KB
- Stars: 159
- Watchers: 7
- Forks: 36
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fast Implementation of Base58 encoding
[](https://godoc.org/github.com/mr-tron/base58) [](https://goreportcard.com/report/github.com/mr-tron/base58)
[](https://sourcegraph.com/github.com/mr-tron/base58?badge)Fast implementation of base58 encoding in Go.
Base algorithm is adapted from https://github.com/trezor/trezor-crypto/blob/master/base58.c
## Benchmark
- Trivial - encoding based on big.Int (most libraries use such an implementation)
- Fast - optimized algorithm provided by this module```
BenchmarkTrivialBase58Encoding-4 123063 9568 ns/op
BenchmarkFastBase58Encoding-4 690040 1598 ns/opBenchmarkTrivialBase58Decoding-4 275216 4301 ns/op
BenchmarkFastBase58Decoding-4 1812105 658 ns/op
```
Encoding - **faster by 6 times**Decoding - **faster by 6 times**
## Usage example
```go
package main
import (
"fmt"
"github.com/mr-tron/base58"
)func main() {
encoded := "1QCaxc8hutpdZ62iKZsn1TCG3nh7uPZojq"
num, err := base58.Decode(encoded)
if err != nil {
fmt.Printf("Demo %v, got error %s\n", encoded, err)
}
chk := base58.Encode(num)
if encoded == string(chk) {
fmt.Printf ( "Successfully decoded then re-encoded %s\n", encoded )
}
}```