Skip to content

Commit

Permalink
cmd/twoproblems: support generating multiple passwords
Browse files Browse the repository at this point in the history
  • Loading branch information
tmthrgd committed Dec 8, 2024
1 parent d2775c2 commit fab3a0b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cmd/twoproblems/twoproblems.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func main() {
}

func main1() error {
count := flag.Int("c", 1, "the number of passwords to generate, one per line")
flag.Parse()

if flag.NArg() != 1 {
Expand All @@ -55,12 +56,15 @@ func main1() error {
return fmt.Errorf("twoproblems: failed to parse %q pattern: %w", flag.Arg(0), err)
}

pass, err := gen.Password(bufio.NewReader(rand.Reader))
if err != nil {
return fmt.Errorf("twoproblems: failed to generate password: %w", err)
r := bufio.NewReader(rand.Reader)
for range *count {
pass, err := gen.Password(r)
if err != nil {
return fmt.Errorf("twoproblems: failed to generate password: %w", err)
}
fmt.Println(pass)
}

fmt.Println(pass)
return nil
}

Expand Down

0 comments on commit fab3a0b

Please sign in to comment.