Golang encoding/base64.Encoding.Decode function examples
package encoding/base64
Decode decodes src(2nd parameter) using the encoding enc. It writes at most DecodedLen(len(src)) bytes to dst(1st parameter) and returns the number of bytes written. If src contains invalid base64 data, it will return the number of bytes successfully written and CorruptInputError. New line characters (\r and \n) are ignored.
Golang encoding/base64.Encoding.Decode function usage examples
Example 1 :
var value []byte
decoded := make([]byte, base64.URLEncoding.DecodedLen(len(value)))
b, err := base64.URLEncoding.Decode(decoded, value)
Example 2 :
authStr = "Mr. Tony"
decLen := base64.StdEncoding.DecodedLen(len(authStr))
decoded := make([]byte, decLen)
authByte := []byte(authStr)
n, err := base64.StdEncoding.Decode(decoded, authByte)
References :
http://golang.org/pkg/encoding/base64/#Encoding.Decode
https://www.socketloop.com/references/golang-encoding-base32-encoding-decode-function-example
Advertisement
Something interesting
Tutorials
+23.9k Golang : Fix type interface{} has no field or no methods and type assertions example
+21.2k Golang : How to get time zone and load different time zone?
+11.7k Golang : Gorilla web tool kit secure cookie example
+8.4k Golang : Generate Datamatrix barcode
+7k Golang : constant 20013 overflows byte error message
+6.2k PHP : Get client IP address
+6k Golang : How to verify input is rune?
+19.9k Golang : How to get time from unix nano example
+4.6k Linux : sudo yum updates not working
+4.7k Adding Skype actions such as call and chat into web page examples
+15.6k Golang : Force download file example
+20.6k Nginx + FastCGI + Go Setup.