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
+4.7k Fix yum-complete-transaction error
+4.9k Golang : How to search a list of records or data structures
+6.4k Golang : Example of how to detect which type of script a word belongs to
+11.9k Golang : Count number of runes in string
+8.2k Golang : Web(Javascript) to server-side websocket example
+10k Use systeminfo to find out installed Windows Hotfix(s) or updates
+7.6k Golang : Convert(cast) []byte to io.Reader type
+22.3k Golang : Check if element exist in map
+5.2k Golang : How to get capacity of a slice or array?
+11.7k Android Studio : Password input and reveal password example
+7.3k Golang : Convert word to its plural form example
+20.4k Golang : Convert seconds to minutes and remainder seconds