Added -S flag to encode spaces as 00

master
Aaron Johnon 1 year ago
parent e6b7a93a33
commit 9c161acc1b

@ -11,9 +11,10 @@ import (
) )
func main() { func main() {
// Define the shift and hex flags // Define the shift, hex, and space flags
shift := flag.Int("s", 0, "Shift value for alphabet positions (can be negative)") shift := flag.Int("s", 0, "Shift value for alphabet positions (can be negative)")
useHex := flag.Bool("x", false, "Encode numbers in hexadecimal") useHex := flag.Bool("x", false, "Encode numbers in hexadecimal")
encodeSpaces := flag.Bool("S", false, "Encode spaces as '00'")
flag.Parse() flag.Parse()
// Check if input is being piped or passed as an argument // Check if input is being piped or passed as an argument
@ -58,6 +59,13 @@ func main() {
} else if unicode.IsDigit(char) { } else if unicode.IsDigit(char) {
// Collect digits to process as a whole number // Collect digits to process as a whole number
currentNumber += string(char) currentNumber += string(char)
} else if char == ' ' && *encodeSpaces {
// Encode space as '00' if the -S flag is set
if currentNumber != "" {
appendNumber(&result, currentNumber, *useHex)
currentNumber = ""
}
result = append(result, "00")
} else { } else {
// If there was a number being processed and now a non-digit/non-letter appears, append it // If there was a number being processed and now a non-digit/non-letter appears, append it
if currentNumber != "" { if currentNumber != "" {

Loading…
Cancel
Save