| // 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 base32_test |
| |
| import ( |
| "encoding/base32" |
| "fmt" |
| ) |
| |
| func ExampleEncoding_EncodeToString() { |
| data := []byte("any + old & data") |
| str := base32.StdEncoding.EncodeToString(data) |
| fmt.Println(str) |
| // Output: |
| // MFXHSIBLEBXWYZBAEYQGIYLUME====== |
| } |
| |
| func ExampleEncoding_DecodeString() { |
| str := "ONXW2ZJAMRQXIYJAO5UXI2BAAAQGC3TEEDX3XPY=" |
| data, err := base32.StdEncoding.DecodeString(str) |
| if err != nil { |
| fmt.Println("error:", err) |
| return |
| } |
| fmt.Printf("%q\n", data) |
| // Output: |
| // "some data with \x00 and \ufeff" |
| } |