![]() Randomly choose one uppercase and one lowercase letter, one digit and one special charecter with string and random module.Print( "Enter a length of password at least 8 :") (we will fill up 4 index with 4 fixed string ) Substract four from the original length and store it in rest_index. take user input of password's length and initialize password string as empty.Import random module and string module in your code.String of ASCII characters which are considered punctuation characters in the C locale: Here is link ![]() This value is not locale-dependent and will not change. The uppercase letters 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'. The lowercase letters 'abcdefghijklmnopqrstuvwxyz'. Used for random sampling without replacement. Random.sample(population, k, *, counts=None) : Return a k length list of unique elements chosen from the population sequence or set. Random.choice(seq) : Return a random element from the non-empty sequence seq. This module implements pseudo-random number generators for various distributions. (I prefer Spyder ide )įunctions and operation we will use random - module : temp = random (Uppercase/ Lowercase/digit/special charecter) if temp=uppercase then pasword+=random uppercase Step 6 : Now in that loop we will choose one string randomly and we will randomly select would that be a uppercase or lowercase or digit or special charecter. password=shuffle the position of all the strings Step 5 : Now for the rest of the strings, we will execute a loop starting from 0 to length-4 (as we have figured four letter first). Step 4 : Now we will shuffle the position of the strings in password so that the index of them become unpredictable as well. password+=radom uppercase+random lowercase + random digit + random special character Now randomly select one Uppercase, one Lowercase, one digit, one special character and store them in a variable. Step 3 : To make sure your password have at least one uppercase, one lowercase letter, one digit and one character, you need to keep 4 space in the index. Step 2 : Substract 4 from the length and store the result in a variable. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.Step 1 : Take a user input of password's length.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |