blob: 40b5438771dac24d9d6dc8c19138231477c7d51c [file] [log] [blame]
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package base64_test
import (
"encoding/base64"
"fmt"
)
func ExampleEncoding_EncodeToString() {
data := []byte("any + old & data")
str := base64.StdEncoding.EncodeToString(data)
fmt.Println(str)
// Output:
// YW55ICsgb2xkICYgZGF0YQ==
}
func ExampleEncoding_DecodeString() {
str := "c29tZSBkYXRhIHdpdGggACBhbmQg77u/"
data, err := base64.StdEncoding.DecodeString(str)
if err != nil {
fmt.Println("error:", err)
return
}
fmt.Printf("%q\n", data)
// Output:
// "some data with \x00 and \ufeff"
}