{"id":12431,"date":"2021-10-01T11:00:40","date_gmt":"2021-10-01T05:30:40","guid":{"rendered":"https:\/\/python-programs.com\/?p=12431"},"modified":"2021-11-22T18:39:28","modified_gmt":"2021-11-22T13:09:28","slug":"secure-passwords-using-python","status":"publish","type":"post","link":"https:\/\/python-programs.com\/secure-passwords-using-python\/","title":{"rendered":"Secure Passwords Using Python"},"content":{"rendered":"
Creating a strong password is essential in everyone’s life nowadays in order to keep your accounts safe and secure. Passwords that are simple and easy to guess can be readily hacked. To avoid this problem, we’ll show you how to create your own safe and secure password using simple Python code.<\/p>\n
Examples:<\/strong><\/p>\n Example1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Below are the ways to write a program that creates the secured passwords.<\/p>\n The best and excellent way to learn a java programming language is by practicing Simple Java Program Examples<\/a> as it includes basic to advanced levels of concepts.<\/p>\n So, before we begin writing code, let’s first talk about the idea behind it. In this application, we will replace a number of characters with various symbols. $, &, @, 0, 1, |, and so on.<\/p>\n So the main idea is to accept the user’s password as input, replace its characters with symbols, and then publish the output for the new strong-produced password for the user.<\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Related Programs<\/strong>:<\/p>\n Creating a strong password is essential in everyone’s life nowadays in order to keep your accounts safe and secure. Passwords that are simple and easy to guess can be readily hacked. To avoid this problem, we’ll show you how to create your own safe and secure password using simple Python code. Examples: Example1: Input: Original …<\/p>\nOriginal Password = Italian<\/pre>\n
The new modified password = |t@l1@n<\/pre>\n
Original Password = albertos<\/pre>\n
The new modified password = @lbert0$<\/pre>\n
Secure Passwords Using Python<\/h2>\n
\n
Method #1: Using For Loop and Replace Function (Static Input)<\/h3>\n
\n
# Take a variable(say secpassword) and create some random characters as tuple\r\n# (('s', '$'), ('and', '&'), ('a', '@'), ('o', '0'), ('i', '1'), ('I', '|')).\r\nsecpassword = (('s', '$'), ('and', '&'),\r\n ('a', '@'), ('o', '0'), ('i', '1'),\r\n ('I', '|'))\r\n# Create a function createSecurePassword() which accepts the given password\r\n# as an argument and returns the secure password.\r\n\r\n\r\ndef createSecurePassword(givenpassword):\r\n # Loop using two variables in the secpassword\u00a0using For loop.\r\n for m, n in secpassword:\r\n # Replace the password with the two variables.\r\n givenpassword = givenpassword.replace(m, n)\r\n # Return the modified Password.\r\n return givenpassword\r\n\r\n\r\n# Give the password as static input and store it in a variable.\r\ngivenpassword = 'Italian'\r\nprint('The original Password = ', givenpassword)\r\n# Pass the given password as an argument to createSecurePassword() function.\r\nmodifiedpassword = createSecurePassword(givenpassword)\r\n# Print the New Modified Password.\r\n\r\nprint('The new modified password = ', modifiedpassword)\r\n<\/pre>\n
The original Password = Italian\r\nThe new modified password = |t@l1@n<\/pre>\n
Method #2: Using For Loop and Replace Function (User Input)<\/h3>\n
\n
# Take a variable(say secpassword) and create some random characters as tuple\r\n# (('s', '$'), ('and', '&'), ('a', '@'), ('o', '0'), ('i', '1'), ('I', '|')).\r\nsecpassword = (('s', '$'), ('and', '&'),\r\n ('a', '@'), ('o', '0'), ('i', '1'),\r\n ('I', '|'))\r\n# Create a function createSecurePassword() which accepts the given password\r\n# as an argument and returns the secure password.\r\n\r\n\r\ndef createSecurePassword(givenpassword):\r\n # Loop using two variables in the secpassword\u00a0using For loop.\r\n for m, n in secpassword:\r\n # Replace the password with the two variables.\r\n givenpassword = givenpassword.replace(m, n)\r\n # Return the modified Password.\r\n return givenpassword\r\n\r\n\r\n# Give the password as user input using the input() function and store it in a variable.\r\ngivenpassword = input('Enter some random password = ')\r\nprint('The original Password = ', givenpassword)\r\n# Pass the given password as an argument to createSecurePassword() function.\r\nmodifiedpassword = createSecurePassword(givenpassword)\r\n# Print the New Modified Password.\r\n\r\nprint('The new modified password = ', modifiedpassword)\r\n<\/pre>\n
Enter some random password = albertos\r\nThe original Password = albertos\r\nThe new modified password = @lbert0$<\/pre>\n
\n