Advertisement
labyrinth-servers1

Password Generator

Mar 27th, 2019
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.82 KB | None | 0 0
  1. package main
  2. import (
  3.     "fmt"
  4.     "math/rand"
  5.     "time"
  6.     )
  7.  
  8.  
  9. var output string = ""
  10. func main() {
  11.     for ok := true; ok; ok = true {
  12.         for i := 0; i < 24; i++ {
  13.             time.Sleep(time.Duration(10) * time.Microsecond) // wait a big because go is so god-damn fast
  14.        
  15.             rand.Seed(time.Now().UTC().UnixNano())
  16.             output = output + randomString(1)
  17.         }
  18.        
  19.         fmt.Println(output) //OUTPUT PASSWORD
  20.        
  21.         // pause the program
  22.         var pause string
  23.         fmt.Scanln(&pause)
  24.        
  25.         output = ""
  26.     } // loop and reset the program if the user wants a new password
  27.    
  28. // end of main function
  29. }
  30.  
  31. func randomString(l int) string {
  32.     bytes := make([]byte, l)
  33.     for i := 0; i < l; i++ {
  34.         bytes[i] = byte(randInt(65, 90))
  35.     }
  36.     return string(bytes)
  37. }
  38.  
  39. func randInt(min int, max int) int {
  40.     return min + rand.Intn(max-min)
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement