Golang encoding/base32.Encoding.EncodedLen function example
package encoding/base32
EncodedLen returns the length in bytes of the base32 encoding of an input buffer of length n(1st parameter).
Golang encoding/base32.Encoding.EncodedLen function usage example
// Base32ExtEncode encodes binary data to base32 extended (RFC 4648) encoded text.
func Base32ExtEncode(data []byte) (text []byte) {
n := base32.HexEncoding.EncodedLen(len(data)) // <--- EncodedLen
buf := bytes.NewBuffer(make([]byte, 0, n))
encoder := base32.NewEncoder(base32.HexEncoding, buf)
encoder.Write(data)
encoder.Close()
if buf.Len() != n {
panic("internal error")
}
return buf.Bytes()
}
Reference :
Advertisement
Something interesting
Tutorials
+10k CodeIgniter : Load different view for mobile devices
+8.2k Golang : Routes multiplexer routing example with regular expression control
+7.2k CloudFlare : Another way to get visitor's real IP address
+14.2k Golang : Fix image: unknown format error
+10.1k Golang : Print how to use flag for your application example
+18.6k Golang : Get download file size
+10k Golang : Get escape characters \u form from unicode characters
+11.7k Golang : Gorilla web tool kit secure cookie example
+34k Golang : Proper way to set function argument default value
+14.5k Golang : Overwrite previous output with count down timer
+46.4k Golang : Encode image to base64 example
+7.7k Golang : Mapping Iban to Dunging alphabets