Skip to content

Commit

Permalink
Update to v0.1.2 (#10)
Browse files Browse the repository at this point in the history
* Remove mean, median, and mode from -vvv

- Did not add direct value
- Calculations were also wrong

* Allow spaces at the end of i and o rules

- Bug fix to allow spaces at the end of i and o rules
- Changes had to be made to the unit tests for TestConvertMultiByteCharToIteratingRule() to expect a space at the end of converted output. This is a change from before where converted output was trimmed before being returned. This logic was duplicated in the calling function so this unit test was updated.

* Increment to version v0.1.2
  • Loading branch information
JakeWnuk committed Apr 28, 2024
1 parent de2f1c0 commit 46842ad
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- All transformations support multibyte characters.

```
Usage of Password Transformation Tool (ptt) version (0.1.1):
Usage of Password Transformation Tool (ptt) version (0.1.2):
ptt [options] [...]
Accepts standard input and/or additonal arguments.
Expand Down
3 changes: 0 additions & 3 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,6 @@ Total Characters: 2758719
Total Words: 585199
Largest frequency: 29529
Smallest frequency: 1
Mean frequency: 1
Median frequency: 1
Mode frequency: 29529

Category Counts:
alphabetical: 496547
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/jakewnuk/ptt/pkg/utils"
)

var version = "0.1.1"
var version = "0.1.2"
var wg sync.WaitGroup
var mutex = &sync.Mutex{}
var retain models.FileArgumentFlag
Expand Down
3 changes: 0 additions & 3 deletions pkg/format/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ func CreateVerboseStats(freq map[string]int) string {
stats += fmt.Sprintf("Total Words: %d\n", totalWords)
stats += fmt.Sprintf("Largest frequency: %d\n", p[0].Value)
stats += fmt.Sprintf("Smallest frequency: %d\n", p[len(p)-1].Value)
stats += fmt.Sprintf("Mean frequency: %d\n", p[len(p)/2].Value)
stats += fmt.Sprintf("Median frequency: %d\n", p[len(p)/2].Value)
stats += fmt.Sprintf("Mode frequency: %d", p[0].Value)

stats += "\n\nCategory Counts:\n"
for category, count := range categoryCounts {
Expand Down
7 changes: 7 additions & 0 deletions pkg/rule/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ func FormatCharToIteratingRuleOutput(index int, strs ...string) (output string)
}
}

if len(output)-3 >= 0 {
// allow for the last character to be a space for overwrite and insert rules
if output[len(output)-3:len(output)-2] == "o" || output[len(output)-3:len(output)-2] == "i" {
output = output + ":"
}
}

if output != "" && len(output) <= 93 {
return strings.TrimSpace(output)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ func ConvertMultiByteCharToIteratingRule(index int, str string) string {
output += " "
}

return strings.TrimSpace(output)
return output
}

// SplitBySeparatorString splits a string by a separator string and returns a slice
Expand Down
8 changes: 4 additions & 4 deletions pkg/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,10 @@ func TestConvertMultiByteCharToIteratingRule(t *testing.T) {

// Define test cases
testCases := TestCases{
{0, "i0l i1o i2v i3e", "i0l i1o i2v i3e"},
{0, "i0a i1爱", "i0a i1\\xE7 i2\\x88 i3\\xB1"},
{1, "i1a i2愛", "i1a i2\\xE6 i3\\x84 i4\\x9B"},
{0, "i0爱 i3t i4e i5s i6t", "i0\\xE7 i1\\x88 i2\\xB1 i3t i4e i5s i6t"},
{0, "i0l i1o i2v i3e", "i0l i1o i2v i3e "},
{0, "i0a i1爱", "i0a i1\\xE7 i2\\x88 i3\\xB1 "},
{1, "i1a i2愛", "i1a i2\\xE6 i3\\x84 i4\\x9B "},
{0, "i0爱 i3t i4e i5s i6t", "i0\\xE7 i1\\x88 i2\\xB1 i3t i4e i5s i6t "},
}

// Run test cases
Expand Down

0 comments on commit 46842ad

Please sign in to comment.