Documentation
¶
Overview ¶
Package base32 implements base32 encoding as specified by RFC 4648.
Index ¶
- Variables
- func NewDecoder(enc *Encoding, r io.Reader) io.Reader
- func NewEncoder(enc *Encoding, w io.Writer) io.WriteCloser
- type CorruptInputError
- type Encoding
- func (enc *Encoding) Decode(dst, src []byte) (n int, err error)
- func (enc *Encoding) DecodeString(s string) ([]byte, error)
- func (enc *Encoding) DecodedLen(n int) int
- func (enc *Encoding) Encode(dst, src []byte)
- func (enc *Encoding) EncodeToString(src []byte) string
- func (enc *Encoding) EncodedLen(n int) int
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 ¶
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