base32

package standard library
go1.8rc2 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2017 License: BSD-3-Clause Imports: 4 Imported by: 9,623

Documentation

Overview

Package base32 implements base32 encoding as specified by RFC 4648.

Index

Examples

Constants

This section is empty.

Variables

View Source
var HexEncoding = NewEncoding(encodeHex)

HexEncoding is the “Extended Hex Alphabet” defined in RFC 4648. It is typically used in DNS.

View Source
var StdEncoding = NewEncoding(encodeStd)

StdEncoding is the standard base32 encoding, as defined in RFC 4648.

Functions

func NewDecoder

func NewDecoder(enc *Encoding, r io.Reader) io.Reader

NewDecoder constructs a new base32 stream decoder.

func NewEncoder

func NewEncoder(enc *Encoding, w io.Writer) io.WriteCloser

NewEncoder returns a new base32 stream encoder. Data written to the returned writer will be encoded using enc and then written to w. Base32 encodings operate in 5-byte blocks; when finished writing, the caller must Close the returned encoder to flush any partially written blocks.

Example
package main

import (
	"encoding/base32"
	"os"
)

func main() {
	input := []byte("foo\x00bar")
	encoder := base32.NewEncoder(base32.StdEncoding, os.Stdout)
	encoder.Write(input)
	// Must close the encoder when finished to flush any partial blocks.
	// If you comment out the following line, the last partial block "r"
	// won't be encoded.
	encoder.Close()
}
Output:
MZXW6ADCMFZA====

Types

type CorruptInputError

type CorruptInputError int64

func (CorruptInputError) Error

func (e CorruptInputError) Error() string

type Encoding