Golang encoding/base32.Encoding.DecodedLen function example
package encoding/base32
DecodedLen returns the maximum length in bytes of the decoded data corresponding to n bytes of base32-encoded data.
Golang encoding/base32.Encoding.DecodedLen function usage example
func packBase32(s []byte) ([]byte, error) {
b32len := base32.HexEncoding.DecodedLen(len(s)) // <---- DecodedLen()
buf := make([]byte, b32len)
n, err := base32.HexEncoding.Decode(buf, []byte(s))
if err != nil {
return nil, err
}
buf = buf[:n]
return buf, nil
}
References :
Advertisement
Something interesting
Tutorials
+9.4k Golang : Scramble and unscramble text message by randomly replacing words
+16.4k Golang : Send email and SMTP configuration example
+18k Golang : Get all upper case or lower case characters from string example
+13.4k Golang : Read from buffered reader until specific number of bytes
+6.4k CodeIgniter : form input set_value cause " to become & quot
+20.9k PHP : Convert(cast) int to double/float
+18.6k Golang : Iterating Elements Over A List
+17.6k Golang : delete and modify XML file content
+9.5k Golang : Changing a RGBA image number of channels with OpenCV
+21.8k SSL : How to check if current certificate is sha1 or sha2
+26.8k Golang : Find files by extension