Created
July 27, 2021 17:45
-
-
Save lrvick/13c7121cc3077d836eb536111bc40cb8 to your computer and use it in GitHub Desktop.
code review
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