Encrypt Your Password Before It is Encrypted

An introductory guide to converting easy-to-remember words to strong passwords. Using the Python programming language.

Image for post
Photo by LinkedIn Sales Navigator on Pexels

In this post, web applications and programming languages ​​are named. There is no intention to advertise the mentioned platforms.

When you are creating a password, I assume that you are about to create a user account for that platform that you want so much. Investing a lot of time to look for a long password with special characters and numbers that the platform asks for is not one of your priorities. However, it is essential to create a strong and hard password for a human or computer to crack.

The security of your credentials to enter your platform is vital so as not to suffer mishaps, identity theft, or denial of service by an attacker or a person close to you who has discovered your access data.

For you, who want so much to start using a platform or application, I offer you the possibility of getting a secure password from your more accessible word to remember. Also, the time taken to create the password is considerably less.

This post is also useful for everyone who wants to encrypt your easy-word to remember and use the result as a password on another platform.

One of the main requirements in any platform that manages user accounts is the length of the password. In the code of the computer program that I provide, you are free to modify that length.

I would dare to say that all platforms encrypt the passwords of their users. If they do not, they must do it in an emergency. That said and applying what I will teach you here; you will have double password encryption. I want this to increase your confidence so that you only deal with your experience on the platforms.

It is unnecessary to download an extra application to run the computer program that I show you below. All you need is an interpreter on the Internet for the Python programming language. If you cannot find one you like, I recommend the Read-eval-print-loop (Repl.it) platform. Python is a scripting programming language that you can run in a browser without a local server or interpreter.

Next, I will explain what the program does with its instructions. The only thing you will have to modify will be the password and salt fields that I will indicate. There is no need for you to have programming skills to run the code and get your password encrypted. Without further ado, let’s get to it.

In the first line, the Python hashlib module is invoked or imported. It contains the functions to perform the encryption. If you run the code in the browser, install this module depends on your platform to run it.

Image for post
Screenshot by the Author

The following line of code sets the length, in bytes, of the result.

Image for post
Screenshot by the Author

A function is defined with the name startEncryption. Inline six, a variable is created that receives the result of executing the pbkdf2_hmac function contained in the Python hashlib module. The function pbkdf2_hmac performs the encryption of the password and the salt.

The pbkdf2_hmac function receives 5 parameters. The name of the hash algorithm (sha256), your password or text to encrypt (this is the text that you must modify), salt (text that sticks to your password, modify it), the iterations of the algorithm, and the length of the encrypted result (in bytes). Remember that you must modify the password, salt, and length (optional if you do not have a character limit).

Inline seven, the value in the hexadecimal format of the variable pwd is returned.

Image for post
Screenshot by the Author

In lines 9 and 10, the startEncryption function is executed, and the console prints the result.

Image for post
Screenshot by the Author

The text that comes out after “Here is your encrypted password:” is the password result of the encryption. You mustn’t modify the rest of the code. You have indeed identified an indentation in the code; this is a crucial feature of the Python programming language.

This section’s remainder is to copy the code and paste it into a Python interpreter on the Internet.

Code by the Author

Check out the Python portal for its documentation if you want to delve into the subject.

Now, enjoy your experience on the platforms, and do not worry about your passwords. You have found a way to turn them into strong passwords.

Greetings.

Written by

I am photography passionate. I write fiction about the interaction between humans, animals, and objects. My impossible love is programming. | IG: eva_perlop

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store