-
-
Save warriorg/5a6aaf5be933686fb1468c7cf4eddde5 to your computer and use it in GitHub Desktop.
This file contains 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
var ( | |
codes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/~!@#$%^&*()_=" | |
codeLen = len(codes) | |
) | |
func RandNewStr(len int) string { | |
data := make([]byte, len) | |
rand.Seed(time.Now().UnixNano()) | |
for i := 0; i < len; i++ { | |
idx := rand.Intn(codeLen) | |
data[i] = byte(codes[idx]) | |
} | |
return string(data) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment