gorfc1751

package module
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2025 License: MIT Imports: 2 Imported by: 1

README

go-rfc1751_logo.png

Mnemonics with RFC1751 format

Go Release License Build Coverage

GoReportCard Activity Commits Downloads GoDoc

About project

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.

Installation

$ go get github.com/number571/go-rfc1751

Requirements

  1. Go version >= 1.16

Functions

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>

License

Licensed under the MIT License. See LICENSE for the full license text.

⬆ back to top

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrIndexWordNotFound = &RFC1751Error{"index word not found"}
	ErrInvalidCheckSum   = &RFC1751Error{"invalid check sum"}
	ErrBitSize           = &RFC1751Error{"bitSize == 0 || bitSize%64 != 0"}
	ErrReader            = &RFC1751Error{"reader"}
)

Functions

func DecodeString

func DecodeString(s string) ([]byte, error)
Example
s := "RASH BUSH MILK LOOK BAD BRIM"
fmt.Println(DecodeString(s))
Output:
[204 172 42 237 89 16 86 190] <nil>

func EncodeToString

func EncodeToString(b []byte) string
Example
b := []byte{204, 172, 42, 237, 89, 16, 86, 190}
fmt.Println(EncodeToString(b))
Output:
RASH BUSH MILK LOOK BAD BRIM

func NewMnemonic

func NewMnemonic(r io.Reader, bitSize uint64) (string, error)
Example
r := rand.New(rand.NewSource(1)) // nolint: gosec
fmt.Println(NewMnemonic(r, 128))
Output:
BARK TROD AMY UP LUG KNOB GAS WHEN NEWT POT KEY MEAN <nil>

Types

type RFC1751Error

type RFC1751Error struct {
	// contains filtered or unexported fields
}

func (*RFC1751Error) Error

func (err *RFC1751Error) Error() string

Directories

Path Synopsis
cmd
mnem command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL