apg-go/apg.go

45 lines
889 B
Go
Raw Permalink Normal View History

2021-03-18 23:26:41 +01:00
package main
import (
"fmt"
"github.com/wneessen/apg.go/config"
"log"
2021-03-18 23:26:41 +01:00
)
// Main function that generated the passwords and returns them
2021-03-18 23:26:41 +01:00
func main() {
// Log config
log.SetFlags(log.Ltime | log.Ldate | log.Lshortfile)
// Create config
conf := config.NewConfig()
conf.ParseParams()
pwLength := conf.GetPwLengthFromParams()
charRange := getCharRange(conf)
// Generate passwords
for i := 1; i <= conf.NumOfPass; i++ {
pwString, err := getRandChar(&charRange, pwLength)
if err != nil {
log.Fatalf("getRandChar returned an error: %q\n", err)
}
switch conf.OutputMode {
case 1:
{
spelledPw, err := spellPasswordString(pwString)
if err != nil {
log.Fatalf("spellPasswordString returned an error: %q\n", err.Error())
}
fmt.Printf("%v (%v)\n", pwString, spelledPw)
2021-03-21 19:25:54 +01:00
break
}
default:
{
fmt.Println(pwString)
break
}
}
}
}