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
+10.4k Golang : Simple Jawi(Yawi) to Rumi(Latin/Romanize) converter
+4.8k PHP : Extract part of a string starting from the middle
+8.8k Golang : Get final balance from bit coin address example
+26.9k Golang : Force your program to run with root permissions
+41.2k Golang : How to count duplicate items in slice/array?
+33k Golang : How to check if a date is within certain range?
+16.4k CodeIgniter/PHP : Create directory if does not exist example
+18.7k Golang : convert int to string
+18.2k Golang : Get command line arguments
+11.3k Golang : Post data with url.Values{}
+16.5k Golang : File path independent of Operating System
+6.9k How to let Facebook Login button redirect to a particular URL ?