CS File (1)
CS File (1)
RANDOM PASSWORD
GENERATOR
COMPUTER SCIENCE
INVSTEGATORY PROJECT
Acknowledgement
Certificate
Introduction
Libraries Used
How to Build
Applications
Advantages & Dissdvantages
Future Scope
Conclusion
ACKNOWLEDGEMENT
Main Function:
The main() function prompts the user for the
number of passwords to generate, as well as the
desired lengths for each password. It then calls
generatePassword() to create the passwords.
Password Validation:
If a user inputs a password length shorter than 3
characters, the program adjusts it to 3 characters as
the minimum length to ensure basic security.
CODE
import random
def generatePassword(pwlength):
alphabet = "abcdefghijklmnopqrstuvwxyz"
passwords = []
for i in pwlength:
password = ""
for j in range(i):
next_letter_index =
random.randrange(len(alphabet))
password = password +
alphabet[next_letter_index]
password =
replaceWithNumber(password)
password =
replaceWithUppercaseLetter(password)
passwords.append(password)
return passwords
CODE
def replaceWithNumber(pword):
for i in range(random.randrange(1,3)):
replace_index =
random.randrange(len(pword)//2)
pword = pword[0:replace_index] +
str(random.randrange(10)) +
pword[replace_index+1:]
return pword
def replaceWithUppercaseLetter(pword):
for i in range(random.randrange(1,3)):
replace_index =
random.randrange(len(pword)//2,len(pword
))
pword = pword[0:replace_index] +
pword[replace_index].upper() +
pword[replace_index+1:]
return pword
CODE
def main():
passwordLengths = []
for i in range(numPasswords):
length = int(input("Enter the length of Password #" +
str(i+1) + " "))
if length<3:
length = 3
passwordLengths.append(length)
Password = generatePassword(passwordLengths)
for i in range(numPasswords):
print ("Password #"+str(i+1)+" = " + Password[i])
main()
EXECUTION
APPLICATIONS
The Random Password Generator can be
used in a variety of real-world applications:
01 Security:
PARTS OF
The passwords generated are highly random,
TESLA’S COIL
making them difficult to guess or crack. They
include a mix of lowercase letters, numbers, and
uppercase letters for increased complexity.
02 Automation:
The program automates the password generation
process, saving time and ensuring consistency in
generating strong passwords.
03 Customizable Length:
Users can specify the length of the password,
allowing them to tailor the strength of the password
to their needs.
DISADVANTAGES
01 Predictability:
PARTS OF
Although the program generates random
TESLA’S COIL
passwords, it could be improved further by adding
additional layers of randomness, such as including
special characters.
02 Limited Complexity:
The password generation relies on a simple
structure (lowercase letters, numbers, and
uppercase letters), which could potentially be weak
if not supplemented with special characters or a
larger character set.
03 Error in Functions:
The functions replaceWithNumber() and
replaceWithUppercaseLetter() return after the first
replacement, making the replacement process
incomplete for certain password lengths.
FUTURE SCOPE