Ad Code

Generate Password And Crack Any Password Using Python.


 Generate Password And Crack Any Password 

Welcome to CodingFizz,



In this tutorial, We will go to write two interesting programs first that will generate a new password using Python, and the second that will be cracking any password using Python.

This tutorial is for the practice of the python programming language. Python is the most popular programming language and most loved programming language, and it's a more easy and simple language for beginners with the comparison of others languages. 

Now, We are going to write programs.

Firstly, we need to import two python modules first is random, and the second is strings

 

Generate Password:

 #import string and random python modules.
 import string
 import random
 if __name__ == '__main__':
    g1 = string.ascii_lowercase
    # print(g1)
    g2 = string.ascii_uppercase
    # print(g2)
    g3 = string.digits
    # print(g3)
    g4 = string.punctuation
    # print(g4)
    pwd_len= int(input("Enter your password length: "))
    p=[]
    p.extend(list(g1))
    p.extend(list(g2))
    p.extend(list(g3))
    p.extend(list(g4))
    # print(p)
    random.shuffle(p)
    print("Your Password: ")
    print("".join(p[0:pwd_len]))

Output:

Enter your password length: 8
Your Password: 
@a<M\=$A

Crack Any Password:

 #import string and random python modules.
 import random
 import string
 your_pass = input("Enter your password: ")
 pwd = string.ascii_lowercase
 guess = ""
 while(guess != your_pass):
    guess = ""
    for letter in range(len(your_pass)):
        g_letter = pwd[random.randint(0, 25)]
        guess = str(g_letter)+str(guess)
    print(guess)
 print('Your Guess Password: ', guess)

 

Output:

Enter Your Password: kn
ir
ls
do
cl
ig
ln
qf
fk
ti
ji
vk
kn
Your Guess Password:  kn

Keep Learning With Us

Post a Comment

0 Comments

Ad Code