From 82b015d819b33e32f8e111e8a4a8343168312a54 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Thu, 14 Mar 2024 09:43:21 +0100 Subject: [PATCH] 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. --- .../simple-password-generator/main.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 example-code/simple-password-generator/main.go diff --git a/example-code/simple-password-generator/main.go b/example-code/simple-password-generator/main.go new file mode 100644 index 0000000..48c35ce --- /dev/null +++ b/example-code/simple-password-generator/main.go @@ -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) +}