Random Password Generator

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 6
At a glance
Powered by AI
The key takeaways are that Python is an easy to learn, powerful programming language with efficient data structures and object-oriented programming capabilities. It is also simple, portable, interpreted and free/open source.

Random strings of a fixed length can be generated in Python by using the random and string modules. The string.ascii_lowercase constant contains all lowercase letters that can be chosen from using random.choice() in a for loop to build up the random string character by character.

The random and string modules are used to generate random strings. The string module contains constants for different character sets. The random module contains functions like random.choice() to pick characters randomly from those sets.

Random

Password
Generator
USING PYTHON
• Python is an easy to learn, powerful programming language.
• It has efficient high-level data structures and a simple but effective
approach to object-oriented programming.
• Python's elegant syntax and dynamic typing, together with its
interpreted nature, make it an ideal language for scripting and rapid
application development in many areas on most platforms.

• FEATURES OF PYTHON
• Simple

About PYTHON •

Easy to Learn
Free and Open Source
• High-level Language
• Portable
• Object Oriented
• Interpreted
• Generate a random string of a fixed
length.
• Generate a random string with lower case
and upper case.
• Generate a random alphanumeric
string with letter and numbers.
TYPES • Generate random string which contains
the letters, digits, and special characters.
• Generate a random password.
• Use the UUID module and secrets module
to generate a secure random string for
the sensitive application.
Generate a random string of fixed length

• String module which contains various string constant which contains the ASCII characters of all cases.
String module contains separate constants for lowercase, uppercase letters, digits, and special characters.
• random module to perform the random generations.
• Use the string constant string.ascii_lowercase to get all the lowercase letter in a single string.
• The string.ascii_lowercase constant contains all lowercase letters. I.e. 'abcdefghijklmnopqrstuvwxyz'
• Run for loop n number of times to pick a single character from a string constant using a random.choice
method and add it to the string variable using a join method. The choice method used to choose the
single character from a list.
• Suppose you want a random string of length 6 then we
can execute a random.choice() method 6 times to pick
a single letter from the string.ascii_lowercase and add It
to the string variable.

• import random
• import string
• def randomString(stringLength=10):
EXAMPLE • """Generate a random string of fixed length """
• letters = string.ascii_lowercase
• return ''.join(random.choice(letters) for i in
range(stringLength))
• print ("Random String is ", randomString() )
• print ("Random String is ", randomString(10) )
• print ("Random String is ", randomString(10) )
OUTPUT
Random String is ptmihemlzj
Random String is dbgxpggrez
Random String is wkhhaghero

You might also like