Posted By

p1p1092 on 02/10/12


Tagged

password python generator


Versions (?)

Python Password Generator


 / Published in: Python
 

A simple python password generator...

  1. import random
  2.  
  3. def main():
  4. while True:
  5. stop = input("Generate password? y/n: ")
  6. if stop and stop[0].lower() == "n":
  7. break
  8.  
  9. length = int
  10.  
  11. size = input("What length do you want the password to be(4-20): ")
  12. length = int(size)
  13.  
  14. chars = string.ascii_letters + string.digits
  15. return ''.join(random.choice(chars) for x in range(length))

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: AnojiRox on September 6, 2012

import string import random

def main(): while True: stop = input("Generate password? y/n: ") if stop and stop[0].lower() == "n": break

    length = int

    size = input("What length do you want the password to be(4-20): ")
    try:
      if int(size)3:
        length=int(size)
      else:
        length=6
   except:
    length=6            
    chars = string.ascii_letters + string.digits
    return ''.join(random.choice(chars) for x in range(length))

Posted By: AnojiRox on September 6, 2012

lol. that failed.

Posted By: AnojiRox on September 6, 2012

import string import random

def main():
    while True:
        stop = input("Generate password? y/n: ")
        if stop and stop[0].lower() == "n":
            break

        length = int

        size = input("What length do you want the password to be(4-20): ")
        try:
          if int(size)3:
            length=int(size)
          else:
            length=6
       except:
        length=6            
        chars = string.ascii_letters + string.digits
        return ''.join(random.choice(chars) for x in range(length))

You need to login to post a comment.