Get the App
SLTechnology News&Howtos  ›  Development  › 

How to generate mixed uppercase and lowercase alphanumeric passwords randomly by python

Shulou Source: shulou.com Published: 2022-06-03 17:08:39 09月20日 Update

This article mainly explains "how to randomly generate uppercase and lowercase alphanumeric mixed passwords by python". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how python can randomly generate mixed uppercase and lowercase alphanumeric passwords.

Use a simple method to generate random passwords

Randomly generate passwords with only 20 lines of code

Core idea: using random module

The random module randomly generates numbers, uppercase and lowercase letters, and cycles.

While cycle + number of randomly generated cycles-- > Random plus++

Capital letters ASKII code between 65 and 90

Lowercase letters Askll code between 97-122,

Final result: X uppercase letters + y digits + z lowercase letters (x _ z is random.

Randomness compared to the previous monotonous lowercase + number + uppercase + lowercase + number + uppercase. The cycle has improved.

Import randomprint ("Random number Generation") time=random.randint (1Magne2) while time: time1=random.randint (1,3) time2=random.randint (1Magne2) time3=random.randint (1,3) while time1: a = random.randint (65Power90) print ("% c"% an Endend = "") time1-=1 while time2: C = random.randint (0Magne99) print ("% d"% c Endend = ") time2-=1 while time3: B = random.randint (97122) print ("% c "% b) End= "") time 3 words 1 time-=1

Add: randomly generate a six-digit CAPTCHA with Python (CAPTCHA consists of numbers and letters (uppercase and lowercase letters))

Import random, the randint function module that randomly generates an interval integer in the random function here knows for the first time that a loop can use for _ in range (): hhh, Def generate_code (code_len = 6): all_char = '0123456789qazwsxedcrfvtgbyhnujmikolpQAZWSXEDCRFVTGBYHNUJIKOLP' index = len (all_char) + 1 code =' 'for _ in range (code_len): num = random.randint (0) Index) code + = all_ char [num] return codeprint (generate_code ())

At this point, I believe you have a deeper understanding of "how to randomly generate uppercase and lowercase alphanumeric mixed passwords by python". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Letters generation numbers size passwords loops uppercase lowercase mixing modules between content functions uppercase letters methods times randomness learning verification utility Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Shulou Tech Info Linux macOS Apple