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
+11.3k Golang : How to use if, eq and print properly in html template
+4.7k Adding Skype actions such as call and chat into web page examples
+12.7k Golang : Sort and reverse sort a slice of bytes
+10k CodeIgniter : Load different view for mobile devices
+8.2k Golang : Metaprogramming example of wrapping a function
+11.2k Golang : Calculate Relative Strength Index(RSI) example
+17.8k Golang : Iterate linked list example
+14.8k Golang : Adding XML attributes to xml data or use attribute to differentiate a common tag name
+12k Golang : Convert a rune to unicode style string \u
+29.1k Golang : Get first few and last few characters from string
+7.9k Golang : Gomobile init produce "iphoneos" cannot be located error