The python implementation randomly generates a program that contains a 8-bit password for uppercase, lowercase letters, and numbers.
Requirements:
1 Number of times the user enters the number of passwords generated,
2 requires that the password must contain both uppercase and lowercase letters and numbers, 8 bits in length, and cannot be duplicated
The code is as follows:
1 Importstring, Random2Src_upp =String.ascii_uppercase3Src_let =string.ascii_letters4Src_num =string.digits5Lis = []6FW = Open ('Password.txt','W')7Count = input ('Please enter the number of times:')8 forIinchRange (int (count)):9 #the number of each of the 3 types is defined randomly (total 8)TenUpp_c = Random.randint (1, 6) OneLet_c = Random.randint (1, 8-upp_c-1) ANum_c = 8-(Upp_c +Let_c) - #randomly generated passwords -Password = random.sample (Src_upp, Upp_c) +random.sample (Src_let, Let_c) +random.sample (Src_num, Num_c) the #disrupting list elements - random.shuffle (password) - #the list is converted to a string -New_password ="'. Join (password) +'\ n' + ifNew_password not inchlis: - Print(New_password) + lis.append (New_password) A fw.write (New_password) atFw.close ()View Code
The results of the operation are as follows:
Generate Password TXT file contents:
Python implementation randomly generates 8-bit cipher applet