Golang encoding/base32.Encoding.Decode function example
package encoding/base32
Decode decodes src(2nd parameter) using the encoding enc. It writes at most DecodedLen(len(src)) bytes to dst(1st parameter) and returns the number of bytes written. If src contains invalid base32 data, it will return the number of bytes successfully written and CorruptInputError. New line characters (\r and \n) are ignored.
Golang encoding/base32.Encoding.Decode function usage example
func packBase32(s string) []byte {
b32len := base32.HexEncoding.DecodedLen(len(s))
buf := make([]byte, b32len)
n, _ := base32.HexEncoding.Decode(buf, []byte(s)) // <----- Decode function
buf = buf[:n]
return buf
}
References :
http://golang.org/pkg/encoding/base32/#Encoding.Decode
https://github.com/skynetservices/skydns/blob/master/nsec3.go
Advertisement
Something interesting
Tutorials
+15.7k Golang : Intercept Ctrl-C interrupt or kill signal and determine the signal type
+11.2k Golang : How to pipe input data to executing child process?
+41.9k Golang : How do I convert int to uint8?
+32.7k Golang : Regular Expression for alphanumeric and underscore
+5k Linux : How to set root password in Linux Mint
+17.2k Google Chrome : Your connection to website is encrypted with obsolete cryptography
+9.3k Golang : Generate EAN barcode
+18.4k Golang : How to get hour, minute, second from time?
+4.4k Golang : Valued expressions and functions example
+13.1k Golang : How to get a user home directory path?
+9.2k Golang : Generate Codabar
+22.6k Generate checksum for a file in Go