-
Notifications
You must be signed in to change notification settings - Fork 31
/
hex.go
68 lines (50 loc) · 1.17 KB
/
hex.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/hex"
type HexEncode struct{}
func (p HexEncode) Name() string {
return "hex-encode"
}
func (p HexEncode) Alias() []string {
return []string{"hex-enc", "hexadecimal-encode"}
}
func (p HexEncode) Transform(data []byte, _ ...Flag) (string, error) {
return hex.EncodeToString(data), nil
}
func (p HexEncode) Flags() []Flag {
return nil
}
func (p HexEncode) Title() string {
return "Hex Encode"
}
func (p HexEncode) Description() string {
return "Encode your text Hex"
}
func (p HexEncode) FilterValue() string {
return p.Title()
}
type HexDecode struct{}
func (p HexDecode) Name() string {
return "hex-decode"
}
func (p HexDecode) Alias() []string {
return []string{"hex-dec", "hexadecimal-decode"}
}
func (p HexDecode) Transform(data []byte, _ ...Flag) (string, error) {
output, err := hex.DecodeString(string(data))
if err != nil {
return "", err
}
return string(output), nil
}
func (p HexDecode) Flags() []Flag {
return nil
}
func (p HexDecode) Title() string {
return "Hex Decode"
}
func (p HexDecode) Description() string {
return "Convert Hexadecimal to String"
}
func (p HexDecode) FilterValue() string {
return p.Title()
}