Advertisement
IsenfireLDC

AutomateTheBoringStuff--Chapter0: Edits 2

May 3rd, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.34 KB | None | 0 0
  1. import math
  2. import random
  3. oddPasswords = ['12345', 'I have a secret password!', '1hi5 15 4 53CR31 P455W0RD', 'HAHAHA']
  4. alpha = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
  5. passwordFile = open('C:\My Stuff\SecretPasswordFile.txt')
  6. secretPassword = passwordFile.read()
  7. print('Enter your password.')
  8. typedPassword = input()
  9. if typedPassword == secretPassword:
  10.     print('Access granted')
  11.     print('Would you like a random password suggestion generator', 'Yes or No')
  12.     permissionRandomGenerator = input().lower()
  13.     print('How long do you want your password?')
  14.     lengthRandomGenerator = int(input())
  15.     if permissionRandomGenerator == 'yes':
  16.         def a():
  17.             return math.floor(random.random()*10)
  18.         def b():
  19.             return alpha[math.floor(random.random()*27)]
  20.         c = []
  21.         d = 0
  22.         while d < lengthRandomGenerator:
  23.             c.insert(d, a())
  24.             d = d + 1
  25.             c.insert(d, b())
  26.             d = d + 1
  27.         d = 0
  28.         if lengthRandomGenerator <= 0:
  29.             print('It has to be longer than that')
  30.         elif lengthRandomGenerator >= 25:
  31.             print('I can\'t generate a password that long')
  32.         elif math.isnan(lengthRandomGenerator):
  33.             print('error: not valid data type')
  34.         else:
  35.             while d < (len(c)-1):
  36.                 e = c[d]
  37.                 print(e)
  38.                 d = d + 1
  39.         d = 0
  40.         c = []
  41.     elif permissionRandomGenerator == 'no':
  42.         print('Too bad...')
  43.     else:
  44.         print('You had to answer Yes or No')
  45.     for w in oddPasswords:
  46.         if w == typedPassword:
  47.             print('BTW:')
  48.             break
  49.     if typedPassword == '12345':
  50.         print('That password is one that an idiot puts on their luggage.')
  51.     if typedPassword == 'I have a secret password!':
  52.         print('Yes you do!')
  53.     if typedPassword == '1hi5 15 4 53CR31 P455W0RD':
  54.         print('Don\'t use machine generated passwords.')
  55.     if typedPassword == 'HAHAHA':
  56.         print('Passwords are know laughing matter')
  57. else:
  58.     if typedPassword == '12345':
  59.         print('How simple do you think my password is?!')
  60.     if typedPassword == 'HAHAHA':
  61.         print('You won\'t be laughing long.')
  62.     print('Access Denied')
  63.     print('Hacker!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement