diff options
-rw-r--r-- | password/gen.go | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/password/gen.go b/password/gen.go index b948a8a..c2b6a91 100644 --- a/password/gen.go +++ b/password/gen.go @@ -1,6 +1,28 @@ package password +import ( + "math/rand" +) + // Generate randomly generates a secure password func Generate() string { - return "hunter21" // TODO + pass := "" + for i := 0; i < 24; i++ { + pass = pass + string(RandChar()) + } + return pass +} + +func RandChar() int { + typ := rand.Intn(3) + if typ == 0 { + // 48-57, numbers + return rand.Intn(10) + 48 + } else if typ == 1 { + // 65-90, uppercase + return rand.Intn(26) + 65 + } else { + // 97-122, lowercase + return rand.Intn(26) + 97 + } } |