In the previous blog post we discussed about Encryption of a file using Caesar Cipher, in this post we discuss a method to decrypt the same file. If you want to view the previous post on Encryption using Caesar Cipher click HERE.
Decryption is a process of decoding the encrypting the encrypted file, to do this we need to know 2 things, the first is the method of encryption and the second is cipher key which in this case is our shift value. once we know these things we can start deciphering the files.
As caesar cipher is a substitution cipher, shift value decides which value is replaced with another value, in encryption we replace each letter by the letter to its right by shift value position, hence now we need to do the opposite, we have to replace each letter by the letter to its left by shift value positions.
So for shift value of 3 we have,
Plaintext : ABCDEFGHIJKLMNOPQRSTUVWXYZ
decipher text : XYZABCDEFGHIJKLMNOPQRSTUVW
Hence every 'a' in our message is replaced by 'x' if the shift value is 3.
consider, Plaintext : "KHOOR, ZHOFRPH WR PB EORJ" will be changed to
Ciphertext: "HELLO, WELCOME TO MY BLOG"
Instead of using only the 26 letters I have also included spaces, symbols and numbers in my cipher hence The following is my keyspace,
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&'( )*+,-./"
In this program we use the same approach as we have used in the encryption code, We have a method that accepts a string and shift value and return a decrypted string. Then we have a method that accepts the path of encrypted file, it reads all the data from that file and sends it to the decryption method and finally makes a file with decrypted message and stores it on the desktop.
Lets get to the code,
Below is the implementation code in cpp, java, python.
C++ Program
Sample input and output to check the program
Data Encryption using Caesar Cipher
LCM of 2 numbers
Anagram Strings
Double Linked List
Finding Middle node in a Linked List
Infix to Prefix Conversion
Infix to Postfix Conversion
Comments
Post a Comment