Last active
March 21, 2017 20:24
-
-
Save bigmeech/ec56b56113935085d176e8d5ad6e7f44 to your computer and use it in GitHub Desktop.
gen 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
| package main | |
| import ( | |
| "fmt" | |
| "math/rand" | |
| "time" | |
| "flag" | |
| ) | |
| func getRandomStrings(str_len int) string { | |
| const str_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&$|#@*_" | |
| rand.Seed(time.Now().UTC().UnixNano()); | |
| data := make([]byte, str_len); | |
| for i := 0; i < str_len; i++ { | |
| data[i] = str_chars[rand.Intn(len(str_chars))]; | |
| } | |
| return string(data) | |
| } | |
| func generatePassword(vargs ...interface{}) string { | |
| if len(vargs) > 0 && vargs[0].(string) != "" { | |
| return vargs[0].(string) + "SALT" | |
| } | |
| return getRandomStrings(10) + "SALT"; | |
| } | |
| func main() { | |
| password := flag.String("p", "", "optional password") | |
| flag.Parse() | |
| pass := generatePassword(*password) | |
| fmt.Println(pass) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment