mirror of
https://github.com/wneessen/apg-go.git
synced 2024-11-22 13:50:49 +01:00
v0.2.0: Added open items
- Added generation of multiple passwords - Added "exclude chars" feature
This commit is contained in:
parent
5d743f70ae
commit
37e73c8c7a
1 changed files with 12 additions and 10 deletions
18
apg.go
18
apg.go
|
@ -7,11 +7,12 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const DefaultPwLenght int = 20
|
const DefaultPwLenght int = 20
|
||||||
const VersionString string = "0.1.0"
|
const VersionString string = "0.2.0"
|
||||||
const PwLowerCharsHuman string = "abcdefghjkmnpqrstuvwxyz"
|
const PwLowerCharsHuman string = "abcdefghjkmnpqrstuvwxyz"
|
||||||
const PwUpperCharsHuman string = "ABCDEFGHJKMNPQRSTUVWXYZ"
|
const PwUpperCharsHuman string = "ABCDEFGHJKMNPQRSTUVWXYZ"
|
||||||
const PwLowerChars string = "abcdefghijklmnopqrstuvwxyz"
|
const PwLowerChars string = "abcdefghijklmnopqrstuvwxyz"
|
||||||
|
@ -54,7 +55,8 @@ func init() {
|
||||||
flag.IntVar(&config.maxPassLen, "x", DefaultPwLenght, "Maxiumum password length")
|
flag.IntVar(&config.maxPassLen, "x", DefaultPwLenght, "Maxiumum password length")
|
||||||
flag.IntVar(&config.numOfPass, "n", 1, "Number of passwords to generate")
|
flag.IntVar(&config.numOfPass, "n", 1, "Number of passwords to generate")
|
||||||
|
|
||||||
// TODO: Exclude chars are missing, yet
|
// String flags
|
||||||
|
flag.StringVar(&config.excludeChars, "E", "", "Exclude list of characters from generated password")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if config.showVersion {
|
if config.showVersion {
|
||||||
|
@ -103,15 +105,15 @@ func main() {
|
||||||
if config.useSpecial {
|
if config.useSpecial {
|
||||||
charRange = charRange + pwSpecialChars
|
charRange = charRange + pwSpecialChars
|
||||||
}
|
}
|
||||||
|
if config.excludeChars != "" {
|
||||||
/*
|
regExp := regexp.MustCompile("[" + config.excludeChars + "]")
|
||||||
for i := 1; i <= config.numOfPass; i++ {
|
charRange = regExp.ReplaceAllLiteralString(charRange, "")
|
||||||
fmt.Println(i)
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
for i := 1; i <= config.numOfPass; i++ {
|
||||||
pwString := getRandChar(&charRange, pwLength)
|
pwString := getRandChar(&charRange, pwLength)
|
||||||
fmt.Println(pwString)
|
fmt.Println(pwString)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRandChar(charRange *string, pwLength int) string {
|
func getRandChar(charRange *string, pwLength int) string {
|
||||||
|
|
Loading…
Reference in a new issue