Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 27th, 2006, 8:48 PM   #1
bulio
Hobbyist Programmer
 
bulio's Avatar
 
Join Date: Jul 2004
Location: Location
Posts: 140
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
Old Feb 27th, 2006, 9:03 PM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 2,035
Rep Power: 6 Sane will become famous soon enough
Send a message via MSN to Sane
Good job. If you plan on doing letters next, be sure to check out the chr() function (if you weren't already aware of it). Just by the way, your 'continue' is unecessary. It would work just the same without it.

Nice work. Now for some fancy graphics. :banana:
Sane is offline   Reply With Quote
Old Feb 28th, 2006, 4:01 AM   #3
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
Nicely done, I can understand most Python code, though I know nothing of it and have never touched it.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:31 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC