Header Ads

Python - WAP to Generate Random Password / String in Python 3.5 - 08

This is a Python Code to Generate Random Password / String using Python 3.5.


Source Code:
#!/usr/bin/python3

# Program to Print a Random String 

while True:

    # Importing built-in functions. 
    import string
    import random

    # Generating a random string. 
    def random_string ( size = 12, string =  string.ascii_lowercase + string.ascii_uppercase + string.digits ):
        return "".join(random.choice(string) for idx in range(size))

    # Printing the Strings. by calling the above function.
    print ("Random Password :", random_string())
    print ("Random Large String :", random_string(size=42))

    print (" - Codegig.org")

    # Continue statement.
    if (input("To Continue ['y'/'n'] : ") == 'y' ):
        continue
    else:
        break

Program Output:


....

No comments