@@ -9,41 +9,39 @@ def RandString(type, length):
99 code = rand .randint (65 , 90 )
1010 response += chr (code )
1111 return response
12+
1213 elif type == "lowercase" :
1314 response = ""
1415 for i in range (length ):
1516 code = rand .randint (97 , 122 )
1617 response += chr (code )
1718 return response
19+
1820 elif type == "upperlower" :
1921 response = ""
20- choices = ["upper" , "lower" ]
2122 code = 0
2223 for i in range (length ):
23- choice = rand .choice ( choices )
24- if choice == "upper" : code = rand .randint (65 , 90 )
24+ choice = rand .randint ( 0 , 1 )
25+ if choice == 0 : code = rand .randint (65 , 90 )
2526 else : code = rand .randint (97 , 122 )
2627 response += chr (code )
2728 return response
29+
2830 elif type == "alphanumerical" :
2931 response = ""
30- choices = ["upper" , "lower" , "number" ]
3132 code = 0
3233 for i in range (length ):
33- choice = rand .choice ( choices )
34- if choice == "upper" : code = rand .randint (65 , 90 )
35- elif choice == "lower" : code = rand .randint (97 , 122 )
34+ choice = rand .randint ( 0 , 2 )
35+ if choice == 0 : code = rand .randint (65 , 90 )
36+ elif choice == 1 : code = rand .randint (97 , 122 )
3637 else : code = rand .randint (48 , 57 )
3738 response += chr (code )
3839 return response
40+
3941 elif type == "ascii" :
4042 response = ""
41- choice = 0
42- code = 0
4343 for i in range (length ):
44- choice = rand .randint (0 , 1 )
45- if choice == 0 : code = rand .randint (33 , 95 )
46- else : code = rand .randint (97 , 125 )
44+ code = rand .randint (33 , 126 )
4745 response += chr (code )
4846 return response
4947 else : raise Exception ("Invalid type in RandString({}, {})" .format (type , length ))
0 commit comments