Created
November 20, 2023 19:42
-
-
Save lrvick/7009e3d2ffe2331a43e894d98bf93627 to your computer and use it in GitHub Desktop.
go pass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func generatePassword(length int) string { | |
const CharSetIAMPassword = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012346789!@#$%^&*()_+-=[]{}|'" | |
charSetLength := len(CharSetIAMPassword) | |
rand.Seed(time.Now().UTC().UnixNano()) | |
result := make([]byte, length) | |
for i := 0; i < length; i++ { | |
result[i] = CharSetIAMPassword[rand.Intn(charSetLength)] | |
} | |
return string(result) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment