Golang encoding/base64.Encoding.EncodeToString function examples
package encoding/base64
EncodeToString returns the base64 encoding of the given input(src).
Golang encoding/base64.Encoding.EncodeToString function usage examples
Example 1 :
func (r *RequestData) Sign(data []byte) string {
hasher := hmac.New(sha1.New, r.SecretKey)
hasher.Write(data)
return base64.StdEncoding.EncodeToString(hasher.Sum(nil))
}
Example 2 :
p := make([]byte, 16)
if _, err := io.ReadFull(rand.Reader, p); err != nil {
return "", err
}
base64.StdEncoding.EncodeToString(p)
Reference :
http://golang.org/pkg/encoding/base64/#Encoding.EncodeToString
Advertisement
Something interesting
Tutorials
+7.2k CloudFlare : Another way to get visitor's real IP address
+9.4k Golang : Web(Javascript) to server-side websocket example
+5.5k Golang : Stop goroutine without channel
+16.8k Golang : read gzipped http response
+26.8k Golang : Find files by extension
+14.4k Golang : How to convert a number to words
+19.1k Mac OSX : Homebrew and Golang
+7.1k Golang : Squaring elements in array
+11.9k Golang : Determine if time variables have same calendar day
+7.5k SSL : How to check if current certificate is sha1 or sha2 from command line
+9k Golang : Populate or initialize struct with values example
+9.4k Facebook : Getting the friends list with PHP return JSON format