Base64 in Go: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * Go Code Examples * Base64 =Overview=")
 
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Internal=
=Internal=
* [[Go Code Examples#Code_Examples|Go Code Examples]]
* [[Go Code Examples#Code_Examples|Go Code Examples]]
* [[Base64]]
* [[Base64#Go|Base64]]
 
=Overview=
=Overview=
=Decoding=
<syntaxhighlight lang='go'>
base64EncodedStr := "..."
data, err := base64.StdEncoding.DecodeString(base64EncodedStr)
if err != nil {
    ...
}
s := string(data)
</syntaxhighlight>
=Encoding=
<syntaxhighlight lang='go'>
base64EncodedStr := base64.StdEncoding.EncodeToString([]byte(str))
</syntaxhighlight>

Latest revision as of 01:53, 13 March 2024

Internal

Overview

Decoding

base64EncodedStr := "..."
data, err := base64.StdEncoding.DecodeString(base64EncodedStr)
if err != nil {
    ...
}
s := string(data)

Encoding

base64EncodedStr := base64.StdEncoding.EncodeToString([]byte(str))