-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9261e7b
commit 01e27e0
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# uuid-base58 | ||
|
||
## Overview | ||
|
||
`uuid-base58` is a small package to generate short [BASE58-string](https://en.bitcoin.it/wiki/Base58Check_encoding) representation of `UUID` and vice versa. | ||
|
||
## Example | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
uuid58 "github.com/AlexanderMatveev/go-uuid-base58" | ||
"github.com/google/uuid" | ||
) | ||
|
||
func main() { | ||
// base58 from UUID | ||
s, _ := uuid58.ToBase58(uuid.MustParse("c73087da-627a-4f00-8786-fcc4f47db57f")) | ||
fmt.Println(s) // RbcZUzUfnGugha7DVu3fAE | ||
|
||
// UUID from base58 | ||
u, _ := uuid58.FromBase58("RbcZUzUfnGugha7DVu3fAE") | ||
fmt.Println(u) // c73087da-627a-4f00-8786-fcc4f47db57f | ||
} | ||
|
||
``` | ||
|
||
## Motivation | ||
|
||
The original Bitcoin client source code explains the reasoning behind base58 encoding: | ||
|
||
**base58.h:** | ||
|
||
``` | ||
// Why base-58 instead of standard base-64 encoding? | ||
// - Don't want 0OIl characters that look the same in some fonts and | ||
// could be used to create visually identical looking account numbers. | ||
// - A string with non-alphanumeric characters is not as easily accepted as an account number. | ||
// - E-mail usually won't line-break if there's no punctuation to break at. | ||
// - Doubleclicking selects the whole number as one word if it's all alphanumeric. | ||
``` |