Base64 in Go: Difference between revisions
Jump to navigation
Jump to search
Line 4: | Line 4: | ||
=Overview= | =Overview= | ||
<syntaxhighlight lang='go'> | |||
l, _ := base64.StdEncoding.Decode(base64Text, []byte(message)) | |||
func base64Encode(str string) string { | |||
return base64.StdEncoding.EncodeToString([]byte(str)) | |||
} | |||
func base64Decode(str string) (string, bool) { | |||
data, err := base64.StdEncoding.DecodeString(str) | |||
if err != nil { | |||
return "", true | |||
} | |||
return string(data), false | |||
} | |||
</syntaxhighlight> |
Revision as of 01:43, 13 March 2024
Internal
Overview
l, _ := base64.StdEncoding.Decode(base64Text, []byte(message))
func base64Encode(str string) string {
return base64.StdEncoding.EncodeToString([]byte(str))
}
func base64Decode(str string) (string, bool) {
data, err := base64.StdEncoding.DecodeString(str)
if err != nil {
return "", true
}
return string(data), false
}