extension String{
static let random_str_characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
static func randomStr(len : Int) -> String{
var ranStr = ""
for _ in 0..<len {
let index = Int(arc4random_uniform(UInt32(random_str_characters.count)))
ranStr.append(random_str_characters[random_str_characters.index(random_str_characters.startIndex, offsetBy: index)])
}
return ranStr
}
}
网友评论