Skip to content

Instantly share code, notes, and snippets.

@lrvick
Created November 20, 2023 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lrvick/7009e3d2ffe2331a43e894d98bf93627 to your computer and use it in GitHub Desktop.
Save lrvick/7009e3d2ffe2331a43e894d98bf93627 to your computer and use it in GitHub Desktop.
go pass
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