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
+12.4k Golang : Flush and close file created by os.Create and bufio.NewWriter example
+8.8k Golang : Combine slices but preserve order example
+23.7k Golang : minus time with Time.Add() or Time.AddDate() functions to calculate past date
+6.8k Golang : Calculate pivot points for a cross
+7k How to let Facebook Login button redirect to a particular URL ?
+7.9k Swift : Convert (cast) String to Double
+7.4k Golang : Individual and total number of words counter example
+12.3k Golang : calculate elapsed run time
+9.7k Golang : Copy map(hash table) example
+20.9k Golang : Underscore or snake_case to camel case example
+6.6k Golang : Map within a map example
+30.2k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?