crock32

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2020 License: ISC Imports: 2 Imported by: 1

README

crock32

ISC License

Package crock32 provides an API for encoding and decoding to and from Douglas Crockford's Base32 encoding.

A comprehensive suite of tests is provided to ensure proper functionality.

Installation and Updating

$ go get -u github.com/ilius/crock32

License

Package crock32 is licensed under the copyfree ISC License.

Documentation

Overview

Package crock32 provides an API for working with modified base32 and Base32Check encodings.

Modified base32 Encoding ...

Base32Check Encoding Scheme

The Base32Check encoding scheme is primarily used for Bitcoin addresses at the time of this writing, however it can be used to generically encode arbitrary byte arrays into human-readable strings along with a version byte that can be used to differentiate the same payload. For Bitcoin addresses, the extra version is used to differentiate the network of otherwise identical public keys which helps prevent using an address intended for one network on another.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckDecode

func CheckDecode(s string) ([]byte, error)

CheckDecode decodes a string that was encoded with CheckEncode and verifies the check byte

func CheckEncode

func CheckEncode(b []byte) string

func Decode

func Decode(b string) ([]byte, error)

Decode decodes a modified base32 string to a byte slice.

Example

This example demonstrates how to decode modified base32 encoded data.

package main

import (
	"fmt"

	"github.com/ilius/crock32"
)

func main() {
	// Decode example modified base32 encoded data.
	encoded := "1A6AWVM41J62X31"
	decoded, err := crock32.Decode(encoded)
	if err != nil {
		panic(err)
	}

	// Show the decoded data.
	fmt.Println("Decoded Data:", string(decoded))

}
Output:
Decoded Data: Test data

func Encode

func Encode(b []byte) string

Encode encodes a byte slice to a modified base32 string.

Example

This example demonstrates how to encode data using the modified base32 encoding scheme.

package main

import (
	"fmt"

	"github.com/ilius/crock32"
)

func main() {
	// Encode example data with the modified base32 encoding scheme.
	data := []byte("Test data")
	encoded := crock32.Encode(data)

	// Show the encoded data.
	fmt.Println("Encoded Data:", encoded)

}
Output:
Encoded Data: 1A6AWVM41J62X31

Types

This section is empty.

Jump to

Keyboard shortcuts

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