Header Banner
Null Byte Logo
Null Byte
wonderhowto.mark.png
Cyber Weapons Lab Forum Metasploit Basics Facebook Hacks Password Cracking Top Wi-Fi Adapters Wi-Fi Hacking Linux Basics Mr. Robot Hacks Hack Like a Pro Forensics Recon Social Engineering Networking Basics Antivirus Evasion Spy Tactics MitM Advice from a Hacker

How to Make a Secret Language with Python

Jun 22, 2015 01:52 PM
Jun 22, 2015 07:06 PM
Women operating an early computer.

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.

Women working on early computing equipment.

Introduce Your Script

At the beginning of every Python script, we have to initialize the modules we must use, and also tell the user what to do.

Python script for a welcome message and user input.
  • 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.

Change Characters of Message

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.

Code snippet demonstrating a character encoding algorithm.
  • 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.

Print Message

Finally, we will print our message. I also wanted a nice little box around our message, so I used:

print ("+")+"-"*len(message)+("+")*

To make a box around the message, size depending on the length of the message.

Python code snippet for message encoding with line breaks.

Make a Decoder

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".

Conclusion

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!

You already know how to use your phone. With Gadget Hacks' newsletter, we'll show you how to master it. Each week, we explore features, hidden tools, and advanced settings that give you more control over iOS and Android than most users even know exists.

Sign up for Gadget Hacks Weekly and start unlocking your phone's full potential.

Related Articles

Comments

No Comments Exist

Be the first, drop a comment!