Another beautiful day in this miserable world

Posts tagged ‘encoder and decoder’

Simple ASCII encoder and decoder using Python

I’m skipping a little bit ahead in the chapters because I think this is pretty cool.

Ever want to send hidden messages to somebody, but don’t know how? Here’s a simple ASCII encoder and decoder for you. You can modify this any way you want, but sure that you change both the encoder and the decoder.

A basic rundown of the program is such:
The program takes the letters of whatever message you are encoding and turns it into the ASCII equivalent. You can find the complete table here ASCII Table . The encoded message you get out of it will just be numbers. Whoever you send the numbers to puts the message into the decoder and that turns the numbers back into letters! Awesome right? Simple, easy, and most normal people don’t know it.

If you want to modify it to be a little bit harder for somebody to catch onto, you could take the numbers that you’re encoding and add 2 or multiply by 7. Remember in the encoder you would have to do the opposite to make the message come out right. Be careful dividing in the encoder, the numbers might not come out right. If you wanted to be really sneaky, You could even do the mod of the number and then find out the numbers equivalent to the mod and have the decode print out what the different messages could be based on the mod. That actually sounds like fun, I might try that sometime 🙂

Remember, my indents are not correct do to the layout of the page. It should look like what’s in the pictures.

Encoder:

def main():
    mess = input("Message: ")

    for ch in mess:
        print(ord(ch), end = " ")
    print()

main()

Decoder:

def main():

    for i in range(10000):
        inString = input("Code: ")

        chars = []
        for numStr in inString.split():
            codeNum = eval(numStr)
            chars.append(chr(codeNum))

        message = "".join(chars)

        print(message)

main()


Here’s a little bit of extra information. Run it through your decoder to find out what it says 🙂

84 104 105 115 32 105 115 32 97 32 118 101 114 121 32 115 105 109 112 108 105 115 116 105 99 32 119 97 121 32 116 111 32 108 101 97 114 110 32 104 111 119 32 110 101 116 119 111 114 107 115 32 97 114 101 32 101 110 99 111 100 101 100 32 97 110 100 32 100 101 99 111 100 101 100 46 32 73 110 32 98 105 103 32 110 101 116 119 111 114 107 115 44 32 116 104 101 114 101 32 105 115 32 117 115 117 97 108 108 121 32 115 111 109 101 32 116 121 112 101 32 111 102 32 97 108 103 111 114 105 116 104 109 32 116 104 97 116 32 100 101 102 105 110 101 115 32 119 104 97 116 32 105 115 32 101 110 99 114 121 112 116 101 100 46 32 84 104 105 115 32 105 115 32 104 111 119 32 99 111 109 112 97 110 105 101 115 32 99 97 110 32 114 101 99 101 105 118 101 32 121 111 117 114 32 99 114 101 100 105 116 32 99 97 114 100 32 110 117 109 98 101 114 32 119 105 116 104 111 117 116 32 105 116 32 98 101 105 110 103 32 104 97 99 107 101 100 32 105 110 32 116 114 97 110 115 105 116 33 32 67 111 111 108 32 114 105 103 104 116 63 32 84 114 121 32 105 116 32 121 111 117 114 115 101 108 102 44 32 115 101 101 32 105 102 32 121 111 117 32 99 97 110 32 99 111 109 101 32 117 112 32 119 105 116 104 32 97 32 99 111 111 108 32 97 108 103 111 114 105 116 104 109 32 58 41