Skip to content
Advertisement

decrypt non alphabetical characters in python ceasar cypher

I found online a working script to try on ceaser cypher, I modified it a bit to be able to decrypt and it’s working well for both sides except one detail:

whenever it’s a special character (non alphabetical) such as: , . ! () ect… it encrypts it like a letter (fine and normal I guess) but once decrypted, these special characters are transformed into a letter, of course it’s still kinda readable, but not fully decrypted as it should.

I’m pretty new to encryption, I’ve looked arround a bit but don’t seem to find any solutions so any insight will be helpful

here is the script:

JavaScript

Advertisement

Answer

this is happening because your encrption and decription “know” just alphabetical chars. your script isn’t generic to all computer chars. try this code for ceaser cypher

JavaScript

I also changed the decrypt function to be the opposite of encryptin because ceaser cypher is Symmetric encryption, in other words, the user give the encrypt and decrypt the same key in both sides.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement