Jim Myhrberg f8ea86748a Switch from string to []byte slices
The way I'm using the base58 required me to do a lot conversions between
[]byte slices and strings. Not anymore.

Also switching to []byte slices allowed some nice performance
improvements.

Before, with strings:

    BenchmarkEncode-4        3000000               511 ns/op
    BenchmarkDecode-4        5000000               300 ns/op

After, with []byte slices:

    BenchmarkEncode-4        5000000               256 ns/op
    BenchmarkDecode-4       20000000               107 ns/op
2016-07-03 11:14:38 +01:00
2016-06-29 00:13:52 +01:00
2016-07-03 11:14:38 +01:00
2016-06-29 00:13:52 +01:00
2016-06-29 00:19:30 +01:00

go-base58 Build Status

A Base58 encoding and decoding package for Go.

What?

Base58 allows you to represent a numeric value with fewer characters, useful for short URLs among other things. Flickr is one the biggest sites that makes use of it for short photo URLs.

For example 6857269519 becomes brXijP when Base58 encoded, and hence the Flickr short URL is: http://flic.kr/p/brXijP

Installation

go get https://github.com/jimeh/go-base58

Usage

import "github.com/jimeh/go-base58"

uid := base58.Encode(6857269519)
fmt.Println(uid) // Prints: brXijP

num, err := base58.Decode('brXijP');
fmt.Println(num) // Prints: 6857269519

Credit

This package is more or less a port of the Base58 Ruby Gem by the same name. Which as far as I can tell, is based on this article by Flickr staff.

License

Released under the MIT license. Copyright (c) 2016 Jim Myhrberg.

Description
Base58 encoding and decoding for Go.
Readme 126 KiB
Languages
Go 100%