Skip to content

Commit

Permalink
feat(company): Add uppercase option
Browse files Browse the repository at this point in the history
Closes #1
  • Loading branch information
qu35t-code committed Jun 14, 2024
1 parent cc5e139 commit d7fcbeb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/company.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var (
includeSpecialChars bool
includeMixedCase bool
includeLeetCode bool
includeUppercase bool
includeMask string
)

Expand Down Expand Up @@ -85,6 +86,7 @@ func init() {
companyCmd.Flags().BoolVar(&includeStartCaps, "start-caps", false, "Capitalize the first letter of the passwords")
companyCmd.Flags().BoolVar(&includeShortYear, "short-year", false, "Truncate the year to the last two digits")
companyCmd.Flags().BoolVarP(&includeLeetCode, "leet", "l", false, "Convert characters to leet speak")
companyCmd.Flags().BoolVarP(&includeUppercase, "uppercase", "u", false, "Capitalize all letters of the passwords")
companyCmd.Flags().StringVarP(&includeMask, "mask", "m", "", "Apply a custom mask to the passwords")
}

Expand Down Expand Up @@ -115,6 +117,10 @@ func generateCompanyPasslist(name, city string) []string {
wordlist = generate.WithLeetCode(wordlist)
}

if includeUppercase {
wordlist = generate.WithUppercase(wordlist)
}

if includeShortYear {
year := time.Now().Year() % 100
var separators string
Expand Down
7 changes: 7 additions & 0 deletions lib/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,10 @@ func applyMask(word, mask, current string, result *[]string, specialChars, digit
applyMask(word, mask[1:], current+string(mask[0]), result, specialChars, digits, lowercase, uppercase, allChars)
}
}

func WithUppercase(wordlist []string) []string {
for _, word := range wordlist {
wordlist = append(wordlist, strings.ToUpper(word))
}
return wordlist
}

0 comments on commit d7fcbeb

Please sign in to comment.