mirror of
https://github.com/wneessen/apg-go.git
synced 2024-12-23 03:30:39 +01:00
Add simple password generator code
Created a new file "main.go" to add a simple password generator script using the apg library. This piece of code generates a random password with a fixed length of 15 characters including special characters, numeric, lower and uppercase letters.
This commit is contained in:
parent
cf47feecbb
commit
82b015d819
1 changed files with 19 additions and 0 deletions
19
example-code/simple-password-generator/main.go
Normal file
19
example-code/simple-password-generator/main.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/wneessen/apg-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
config := apg.NewConfig(apg.WithAlgorithm(apg.AlgoRandom),
|
||||
apg.WithModeMask(apg.ModeSpecial|apg.ModeNumeric|apg.ModeLowerCase|apg.ModeUpperCase),
|
||||
apg.WithFixedLength(15))
|
||||
generator := apg.New(config)
|
||||
password, err := generator.Generate()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("Your password:", password)
|
||||
}
|
Loading…
Reference in a new issue