This question already has an answer here: Finding length of .... From the random string generated you ...
stackoverflow.com