...
1
2
3
4
5
6
7 package base32_test
8
9 import (
10 "encoding/base32"
11 "fmt"
12 "os"
13 )
14
15 func ExampleEncoding_EncodeToString() {
16 data := []byte("any + old & data")
17 str := base32.StdEncoding.EncodeToString(data)
18 fmt.Println(str)
19
20
21 }
22
23 func ExampleEncoding_DecodeString() {
24 str := "ONXW2ZJAMRQXIYJAO5UXI2BAAAQGC3TEEDX3XPY="
25 data, err := base32.StdEncoding.DecodeString(str)
26 if err != nil {
27 fmt.Println("error:", err)
28 return
29 }
30 fmt.Printf("%q\n", data)
31
32
33 }
34
35 func ExampleNewEncoder() {
36 input := []byte("foo\x00bar")
37 encoder := base32.NewEncoder(base32.StdEncoding, os.Stdout)
38 encoder.Write(input)
39
40
41
42 encoder.Close()
43
44
45 }
46
View as plain text