The RFC1751 encoding in Go language. The code is mostly rewritten from the Python implementation. Tested on examples of repositories remram44/python-rfc1751, vmizg/rfc1751.js, arokettu/php-rfc1751.
$ go get github.com/number571/go-rfc1751
- Go version
>= 1.16
r := rand.New(rand.NewSource(1)) // insecure: used math/rand
fmt.Println(NewMnemonic(r, 128))
// Output: BARK TROD AMY UP LUG KNOB GAS WHEN NEWT POT KEY MEAN
b := []byte{204, 172, 42, 237, 89, 16, 86, 190}
fmt.Println(EncodeToString(b))
// Output: RASH BUSH MILK LOOK BAD BRIM
s := "RASH BUSH MILK LOOK BAD BRIM"
fmt.Println(DecodeString(s))
// Output: [204 172 42 237 89 16 86 190] <nil>
Licensed under the MIT License. See LICENSE for the full license text.