mirror of
https://github.com/wneessen/apg-go.git
synced 2024-11-22 13:50:49 +01:00
37 lines
907 B
Go
37 lines
907 B
Go
package main
|
|
|
|
import "regexp"
|
|
|
|
// Provide the range of available characters based on provided parameters
|
|
func getCharRange() string {
|
|
pwUpperChars := PwUpperChars
|
|
pwLowerChars := PwLowerChars
|
|
pwNumbers := PwNumbers
|
|
pwSpecialChars := PwSpecialChars
|
|
if config.humanReadable {
|
|
pwUpperChars = PwUpperCharsHuman
|
|
pwLowerChars = PwLowerCharsHuman
|
|
pwNumbers = PwNumbersHuman
|
|
pwSpecialChars = PwSpecialCharsHuman
|
|
}
|
|
|
|
var charRange string
|
|
if config.useLowerCase {
|
|
charRange = charRange + pwLowerChars
|
|
}
|
|
if config.useUpperCase {
|
|
charRange = charRange + pwUpperChars
|
|
}
|
|
if config.useNumber {
|
|
charRange = charRange + pwNumbers
|
|
}
|
|
if config.useSpecial {
|
|
charRange = charRange + pwSpecialChars
|
|
}
|
|
if config.excludeChars != "" {
|
|
regExp := regexp.MustCompile("[" + regexp.QuoteMeta(config.excludeChars) + "]")
|
|
charRange = regExp.ReplaceAllLiteralString(charRange, "")
|
|
}
|
|
|
|
return charRange
|
|
}
|