-
Notifications
You must be signed in to change notification settings - Fork 31
/
base32.go
68 lines (51 loc) · 1.34 KB
/
base32.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package processors
import (
"encoding/base32"
)
// Base32Encoding encode string to base64.
type Base32Encoding struct{}
func (p Base32Encoding) Name() string {
return "base32-encode"
}
func (p Base32Encoding) Alias() []string {
return []string{"b32-enc", "b32-encode"}
}
func (p Base32Encoding) Transform(data []byte, _ ...Flag) (string, error) {
return base32.StdEncoding.EncodeToString(data), nil
}
func (p Base32Encoding) Flags() []Flag {
return nil
}
func (p Base32Encoding) Title() string {
return "Base32 Encoding"
}
func (p Base32Encoding) Description() string {
return "Encode your text to Base32"
}
func (p Base32Encoding) FilterValue() string {
return p.Title()
}
// Base32Decode decode string from base64 to plain text.
type Base32Decode struct{}
func (p Base32Decode) Name() string {
return "base32-decode"
}
func (p Base32Decode) Alias() []string {
return []string{"b32-dec", "b32-decode"}
}
func (p Base32Decode) Transform(data []byte, _ ...Flag) (string, error) {
decodedString, err := base32.StdEncoding.DecodeString(string(data))
return string(decodedString), err
}
func (p Base32Decode) Flags() []Flag {
return nil
}
func (p Base32Decode) Title() string {
return "Base32 Decode"
}
func (p Base32Decode) Description() string {
return "Decode your base32 text"
}
func (p Base32Decode) FilterValue() string {
return p.Title()
}