ios - Swift Iteration Character Length -
this question has answer here:
- generate random alphanumeric string in swift 16 answers
i in process of making 1 of first apps, aim of password generator , telling people on scale of 1-1000 how hard guess, , how hard remember based on how letters formatted , looks , how brain remembers patterns. far have characters want use in array, , have in loop iterates through characters, can't figure out how specify length of password generate, prints each character. so, asking how can make 8 character long password generator possible, have far is:
import foundation let chars = ["a","b","c","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u" ,"v","w","x","y","z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"]
thank you!
var generate: string generate in chars { print(generate) }
as possible use loop , and random number character @ given index:
let length = 8 var pass = "" _ in 0..<length { let random = arc4random_uniform(uint32(chars.count)) pass += chars[int(random)] } print(pass)
Comments
Post a Comment