How To: Make a Secret Language with Python

Make a Secret Language with Python

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.

Step 1: 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.

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

Step 2: 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.

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

Step 3: 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.

Step 4: 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".

Step 5: 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!

18 Comments

Brilliant idea of a guide for Null Byte! Really shows a very interesting mindset to face programming with.

Wow, that takes some time! Thanks for sharing the idea.

Your welcome! I'm kind of new to python as well so I couldn't exactly put together an easier way of doing this. One idea I had was to have a list or dictionary with the alphabet and the characters you wish to replace, but...oh well.

Well, what you have here is surely amazing. I never thought of making a secret language. I've only made a Piglatin translator. XD

Haha! Not bad! and Thank you!

Nice code, I always wondered how to substitute a single character out of a string.

Btw, why do you delay the script? To make it look like the computer is working on it?

It makes it better organized, I guess.

What Cracker Hacker said. I'm able to view and understand my script more easily from a user perspective.

Can I just suggest using None instead of ""?

Finally! I've been trying to figure out a better way to do that. I know \n worked but I understood print "" pretty well.

Also, you can use "Random text...\n" instead of
"Random text..."
print ""

Edit: Wrong page, too many windows open and too late in the night.

nice post! shows the basics of cryptography very well! once i get some more time again, i'll try to look into it and add an encryption key to it!

-Phoenix750

Guys, the same thing can be done much easier like this..

-----------------------------------------------------------------------------------------
import string

original = "secret or whatever you wanna encode/decode here"

table = string.maketrans(
"abcdefghijklmnopqrstuvwxyz", "efghijklmno$qrstuvwxyzabcd"
)

print original.translate(table)
-----------------------------------------------------------------------------------------

You put the string you want to encode/decode in the 'original' variable. and in the 'table' variable there are 2 sets of strings, translate will automatically switch for the position, meaning 'a' will be 'e', 'l' will be '$', and so on.. You can even swap a letter for a whole word, a list, special character, etc. endless options. :)

Ahhh, the magic of tables. <3

Share Your Thoughts

  • Hot
  • Latest