apg-go/chars.go

38 lines
889 B
Go
Raw Normal View History

2021-03-21 14:05:14 +01:00
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("[" + config.excludeChars + "]")
charRange = regExp.ReplaceAllLiteralString(charRange, "")
}
return charRange
}