Secure Your Current Password using Python

Secure Your Current Password using Python: Hello, Awesome people, we already make our own password generator in the previous post. It is working fine right. But it’s hard to remember right. So, I decide to make another python program that makes your current password more secure and it is easy to remember. So, let’s secure the current password using python.

Goal

So, we just exchange some of the characters in current password string that similar to another character like a replace with @, i with ! and more.

Coding

First we make tuple that define which character replace with which one. So here the code.

SECURE = (("s", "$"), ("and", "&"), ("a", "@"), ("o", "0"), 
("i", "!"))

You can extend this tuple with more character.

Now, we define a function that replace the character from string that I passed.

def securePassword(password):
    for a, b in SECURE:
        password = password.replace(a, b)

    return password

Now, we simply ask user to get password string to convert into new secure password.

if __name__ == "__main__":
    password = input("Enter your password: ")
    print(f"Your new secure password: {securePassword(password.lower())}")

See, here I converted the string in lower case then I passed into a function. Because I want to replace it with the same character for lower as well as upper case character. But it is up to you, you can also extend the tuple.

Final Code

SECURE = (("s", "$"), ("and", "&"), ("a", "@"), ("o", "0"), ("i", "!"))

def securePassword(password):
    for a, b in SECURE:
        password = password.replace(a, b)

    return password

if __name__ == "__main__":
    password = input("Enter your password: ")
    print(f"Your new secure password: {securePassword(password.lower())}")

Output

Enter your password: spiderman
Your new secure password: $p!derm@n

So, this is a simple code to make your password secure. So, this is how I secure my password. Must try and extend it.

Also see:

Leave a Comment

Copy link
Powered by Social Snap