Golang encoding/base32.NewEncoding function examples

package encoding/base32

NewEncoding returns a new Encoding defined by the given alphabet, which must be a 32-byte string.

Golang encoding/base32.NewEncoding function usage examples

Example 1 :

 var simpleSubdomainSafeEncoding = base32.NewEncoding("0123456789abcdefghijklmnopqrstuv")

Example 2 :

 const encodeStd = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
 const encodeHex = "0123456789ABCDEFGHIJKLMNOPQRSTUV"

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

 var StdEncoding = NewEncoding(encodeStd)

 // HexEncoding is the ``Extended Hex Alphabet'' defined in RFC 4648.
 // It is typically used in DNS.

 var HexEncoding = NewEncoding(encodeHex)

References :

http://golang.org/pkg/encoding/base32/#NewEncoding

http://golang.org/src/pkg/encoding/base32/base32.go

Advertisement