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
+29.2k Golang : missing Git command
+13.2k Golang : Convert(cast) int to int64
+7.3k Golang : Of hash table and hash map
+23.6k Golang : minus time with Time.Add() or Time.AddDate() functions to calculate past date
+15.2k JavaScript/JQuery : Detect or intercept enter key pressed example
+6.8k Golang : Find the longest line of text example
+14k Golang : convert rune to unicode hexadecimal value and back to rune character
+29.9k Golang : Get and Set User-Agent examples
+12.7k Golang : zlib compress file example
+7.5k Golang : Dealing with struct's private part
+5.2k Golang : Calculate half life decay example
+5k Python : Convert(cast) bytes to string example