Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

README.md

basen

GoDoc Build Status codecov Report card

Package basen implements a radix encoding/decoding scheme, defined by a n-character alphabet.

import "github.com/nicksnyder/basen"

base62

Base62 encoding encodes data using the character set 0-9A-Za-z. It is useful for generating strings that are safe to include in URLs, and allows easy copy and paste because a double-click will usually select the whole string.

Encode:

encoded := basen.Base62Encoding.EncodeToString([]byte("Hello"))
fmt.Println(encoded) // 5TP3P3v

Decode:

decoded, _ := basen.Base62Encoding.DecodeString("5TP3P3v")
fmt.Println(string(decoded)) // Hello

base58

Base58 encoding is base62 encoding modified to avoid letters which might look ambiguous when printed (i.e. 0, O, I, l). This reduces the risk of errors when a human is manually copying from some visual source.

Encode:

encoded := basen.Base58Encoding.EncodeToString([]byte("Hello"))
fmt.Println(encoded) // 9Ajdvzr

Decode:

decoded, _ := basen.Base58Encoding.DecodeString("9Ajdvzr")
fmt.Println(string(decoded)) // Hello

About

A base62 and base58 encoding library for Go

Topics

Resources

License

Packages

No packages published

Languages

You can’t perform that action at this time.