Sometimes our information important. So important that we have to encode it to keep it away from criminals. What better way to encode information than to make our own encoder with Python?
In this tutorial, we will cover the basics of cryptography in hopes to make a "gibberish" language.
At the beginning of every Python script, we have to initialize the modules we must use, and also tell the user what to do.
- The first line is mandatory for any Python script. It tells our terminal that we are using Python.
- The second line of this script imports the time module. This will allow us to delay our script for a desired amount of seconds with time.sleep(seconds).
- The third and fourth line are just a header for our script, so the user knows what this is.
- The fifth line uses the time.sleep() function we talked about earlier.
- The sixth line asks our user for the message to encode. We use "raw_input()" to capture what the user types.
- The seventh line creates an empty string where our final encoded message will be stored.
In the next portion of this script, we will use a for loop, and an if else statement. The for loop will say, for every character (char) in this message (message), check to see which character is being used, and convert it to a different character of my choice. Finally, we will add each character to the empty string.
- First of all, we say for every character in this message, do the following. We can say that by using the for loop. "For char in message:"
- Then we go through the alphabet, lowercase and uppercase, and say, "if this character is an a, change it to a #, if this character is a b change it to a *" and so on. Also, when we change these characters, we add them to the final message, called "encoded" by using +=. At the end of the for loop, we use an else command for special characters that we don't need to encode.
Finally, we will print our message. I also wanted a nice little box around our message, so I used:
To make a box around the message, size depending on the length of the message.
To make a message decoder, just repeat the process of making the encoder, except swap each character in the for loop. For example, if we changed an "A" to a "#" in our encoder, than simply make it so that if the message contains a "#" it will change to an "A".
Wow! We made a new language in little to no time!
The script used in this tutorial can be found here:
And as always, )4 aqm j#x@ #pa $m@uv)qpu qt 3qp3@tpu, n@#x@ vj@0 )p vj@ 3q00@pv u@3v)qp.
Thanks for reading!
Want to start making money as a white hat hacker? Jump-start your hacking career with our 2020 Premium Ethical Hacking Certification Training Bundle from the new Null Byte Shop and get over 60 hours of training from cybersecurity professionals.
Other worthwhile deals to check out: