...
|
...
|
@@ -39,13 +39,20 @@ func AssertJson(object interface{})string{ |
|
|
|
|
|
var randomChars = "ABCDEFGHJKMNPQRSTWXYZabcdefhjkmnprstwxyz2345678" /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
|
|
|
func RandomString(l int)string{
|
|
|
return RandomStringWithChars(l,randomChars)
|
|
|
}
|
|
|
|
|
|
func RandomStringWithChars(l int,chars string)string{
|
|
|
if l<=0{
|
|
|
return ""
|
|
|
}
|
|
|
lenChars :=len(randomChars) -1
|
|
|
if len(chars)==0{
|
|
|
return ""
|
|
|
}
|
|
|
lenChars :=len(chars) -1
|
|
|
rsp :=bytes.NewBuffer(nil)
|
|
|
for i:=0;i<l;i++{
|
|
|
rsp.WriteByte(randomChars[rand.Intn(lenChars)])
|
|
|
rsp.WriteByte(chars[rand.Intn(lenChars)])
|
|
|
}
|
|
|
return rsp.String()
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|