Question: create a Ruby program that will take a key word and a text file then print out the encrypted text message. For instance, here is

create a Ruby program that will take a key word and a text file then print out the encrypted text message. For instance, here is a run of the program:

> encrypt

Enter the cipher key > honey

Enter the text file > mythoughts.txt

Enter the encrypted file > mysecret.txt

> encrypt -d

Enter the cipher key > honey

Enter the encrypted file > mysecret.txt

Enter the text file > mythoughts.txt

In the above examples of execution, the first encrypts the file 'mythoughts.txt' to 'mysecret.txt' using the key 'honey' to create the cipher. The second execution decrypts the message in 'mysecrets.txt' using the key 'honey' to create the cipher then writing the deciphered text in 'mythoughts.txt'. Realize that when decrypting, we are reversing the roles of the cipher and the alphabet in substitution for the text. When we encrypt the message, the alphabet character in the text is substituted using the cipher character, but when we decrypt the message, the cipher character in the encrypted text is substituted using the alphabet character.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!