Share your repls and programming experiences

← Back to all posts
AsciiCipher - Ciphering made easy.
ChezCoder (1458)

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:

UsageParamsReturn Val
create_key()None: Noneint: key
cipher()str: message, int: keystr: ciphered
decipher()str: message, int: keystr: deciphered

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!

Commentshotnewtop
techgeek680 (65)

doesnt let me put in password

ChezCoder (1458)

@techgeek680 that is because this is a module, meaning you can just use it like this:
import acrypt

techgeek680 (65)

Thank you. Amazing game! @ChezCoder

ChezCoder (1458)

@techgeek680 oh, lol this is not a game. Its a module in python that i made :D

techgeek680 (65)

i legit just found out how to upvote :) @ChezCoder

(so i did)

AtticusKuhn (236)

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.

ChezCoder (1458)

@AtticusKuhn oof... im going to try a longer key, maybe 50 digits?

ChezCoder (1458)

@AtticusKuhn Thanks for the suggestion! Im creating the project on pypi. Do you want to help?