Hello repl.it community! So recently, I was working on this login system. I wanted to not only encode passwords but also usernames. This, of course, meant I had to use ciphers. Ciphers are complicated. Very very complicated. I only wanted to encrypt and decrypt a string of characters so many of the steps in ciphering seemed very pointless. So... I made this! AsciiCipher is a very simple ciphering system, three functions:
Ciphering was suddenly made so much more easy!
create_key() - Generate a valid key for the ciphers.
cipher(MESSAGE,KEY) - Cipher a message with a key!
decipher(MESSAGE,KEY) - Decipher a message with a key!
See? Only three functions. And one of them is for debugging. This cipher is pretty secure. Here is the format for the key:
- 9 digits
- No 0's
For those who don't know what a key is, it's basically a string that tells the cipherer what pattern to use for the encryption. So basically keep this secret! Here what the docs say on keeping secrets.
Want to know how it ciphers? Here is a step by step process of the ciphering:
- Convert each letter in the message into it's corresponding ascii code, the code must be 3 letters so convert it into a string and add zeros to the end of the ascii code if the length isn't 3.
- Generate a random toggle number to decide wether to add first or subtract first. The toggle number toggles adding and subtracting the nth letter of the key to the ascii code.
- Add the numbers back into a single string and add the toggle number to the beginning so the decipherer knows which toggle number to begin with.
and done! Deciphering is much simpler because I basically just reversed the ciphering process. Have fun!
Please upvote! This spent me a lot of time. Show that you care!
I think this might not be secure. There are 9^9 possibilities for the key, which might not be enough. For example, AES uses a 128 bit key, which has 2^128 possibilities.