calfred2808

#Python Crack a password

Jul 19th, 2020
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. # importing random
  2. from random import *
  3.  
  4. # taking input from user
  5. user_pass = input("Enter your password: "+ "\n")
  6.  
  7. # storing alphabet letter to use thm to crack password
  8. password = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j','k',
  9.             'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't','u','v',
  10.             'w', 'x', 'y', 'z',]
  11.  
  12. # initializing an empty string
  13. guess = ""
  14.  
  15.  
  16. # using while loop to generate many passwords untill one of
  17. # them does not matches user_pass
  18. while (guess != user_pass):
  19.     guess = ""
  20.     # generating random passwords using for loop
  21.     for letter in range(len(user_pass)):
  22.         guess_letter = password[randint(0, 25)]
  23.         guess = str(guess_letter) + str(guess)
  24.     # printing guessed passwords
  25.     print(guess)
  26.    
  27. # printing the matched password
  28. print("Your password is",guess)
Add Comment
Please, Sign In to add comment