Skip to content

Commit

Permalink
Add multiplier generator
Browse files Browse the repository at this point in the history
  • Loading branch information
marcwickenden committed Jan 24, 2024
1 parent ee20e69 commit 1e65612
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
13 changes: 9 additions & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
builds:
- main: .
binary: corpass
ldflags:
- -extldflags '-static'
- -X main.version={{.Version}}
flags:
- -trimpath
env:
- CGO_ENABLED=0
- CGO_ENABLED=0
asmflags:
- all=-trimpath={{.Env.GOPATH}}
gcflags:
- all=-trimpath={{.Env.GOPATH}}
ldflags: |
-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -extldflags '-static'
goos:
- linux
- darwin
Expand Down
33 changes: 33 additions & 0 deletions generators/multiplier/multiplier.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package multiplier

import "fmt"

type MultiplierGenerator struct {
count int
}

func NewMultiplierGenerator() *MultiplierGenerator {
return &MultiplierGenerator{
count: 2,
}
}

func (g *MultiplierGenerator) Name() string {
return "multiplier"
}

func (g *MultiplierGenerator) WithCount(i int) {
g.count = i
}

func (g *MultiplierGenerator) Generate(input string) ([]string, error) {
results := []string{}

result := input
for i := 2; i <= g.count; i++ {
result = fmt.Sprintf("%s%s", result, input)
results = append(results, result)
}

return results, nil
}
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/4armed/corpass/generators"
"github.com/4armed/corpass/generators/leet"
"github.com/4armed/corpass/generators/multiplier"
"github.com/4armed/corpass/generators/numerics"
"github.com/4armed/corpass/generators/punctuation"
"github.com/4armed/corpass/generators/upperlower"
Expand All @@ -27,7 +28,7 @@ var (
)

func main() {
flag.StringVar(&generatorList, "generators", "upperlower,leet,numerics,punctuation", "comma separated list of generators to use")
flag.StringVar(&generatorList, "generators", "upperlower,leet,numerics,punctuation,multiplier", "comma separated list of generators to use")
flag.BoolVar(&verbose, "verbose", false, "enable verbose logging")
flag.BoolVar(&printVersion, "version", false, "print version and exit")
flag.Usage = func() {
Expand Down Expand Up @@ -63,6 +64,7 @@ func main() {
g.MustRegisterGenerator(leet.NewLeetGenerator())
g.MustRegisterGenerator(numerics.NewNumericsGenerator())
g.MustRegisterGenerator(punctuation.NewPunctuationGenerator())
g.MustRegisterGenerator(multiplier.NewMultiplierGenerator())

// Process the generator list
generators := strings.Split(generatorList, ",")
Expand Down

0 comments on commit 1e65612

Please sign in to comment.