Skip to content

Commit

Permalink
Add string ops (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
joohoi authored May 13, 2021
1 parent d98b7d4 commit 397e922
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ HASHES
OTHER
filename.tmpl - Replaces string #PAYLOAD# in content of a file that has .tmpl extension.
lower - Convert string to lowercase
upper - Convert string to uppercase
```

Expand Down
2 changes: 2 additions & 0 deletions pkg/pencode/encoders.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var availableEncoders = map[string]Encoder{
"hexdecode": HexDecoder{},
"jsonescape": JSONEscaper{},
"jsonunescape": JSONUnescaper{},
"lower": StrToLower{},
"md5": MD5Hasher{},
"sha1": SHA1Hasher{},
"sha224": SHA224Hasher{},
Expand All @@ -22,6 +23,7 @@ var availableEncoders = map[string]Encoder{
"sha512": SHA512Hasher{},
"unicodedecode": UnicodeDecode{},
"unicodeencodeall": UnicodeEncodeAll{},
"upper": StrToUpper{},
"urlencode": URLEncoder{},
"urldecode": URLDecoder{},
"urlencodeall": URLEncoderAll{},
Expand Down
32 changes: 32 additions & 0 deletions pkg/pencode/strings.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package pencode

import (
"strings"
)

type StrToUpper struct{}
type StrToLower struct{}

func (s StrToUpper) Encode(input []byte) ([]byte, error) {
return []byte(strings.ToUpper(string(input))), nil
}

func (s StrToUpper) HelpText() string {
return "Convert string to uppercase"
}

func (s StrToUpper) Type() string {
return "other"
}

func (s StrToLower) Encode(input []byte) ([]byte, error) {
return []byte(strings.ToLower(string(input))), nil
}

func (s StrToLower) HelpText() string {
return "Convert string to lowercase"
}

func (s StrToLower) Type() string {
return "other"
}

0 comments on commit 397e922

Please sign in to comment.