View Single Post
Old Feb 27th, 2006, 7:48 PM   #1
bulio
Hobbyist Programmer
 
bulio's Avatar
 
Join Date: Jul 2004
Location: Location
Posts: 138
Rep Power: 5 bulio is on a distinguished road
[Python] Password Generator

Just a basic password generator that I did while programming python yesterday. It actually works ok. (Maybe I should try mixing letters and numbers next)

#This program generates a random password based on numbers
#Copyright Bulio, 2006'''

import random

print "Welcome to the random password generator"
print "Make a choice to continue."

while True:
    
    choice = raw_input("1.Generate a password\n2.Exit\n") # Get user input
    
    if choice == "1": 
        try:
       
          length = raw_input("Enter the length of your password now, with a minimum of 8 digits: ")
          pword = random.randint(30000,length) #Generate the random password now
          print "Your password recommended password is: ", pword #Print the random password
          break 
        except ValueError:
          print "Not a real number. Please enter another."  
           
    elif choice == "2": 
        print "Quitting now"
        break
        
    else:
        print "Invalid choice. Please type either 1 or 2.\n"
        continue
bulio is offline   Reply With Quote