Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C++ The goal of part B is to create a program to encode files and strings using the rot13 encoding method. Information about the

Using C++

The goal of part B is to create a program to encode files and strings using the rot13 encoding method. Information about the rot13 method can be found at http://www.rot13.com/.

Implement the rot13 algorithm using functions, strings and file I/O. You program should use at least 3 to 4 functions. It should be able to read in a text file from a specified filename, encode using rot13, and write it to a specified file. It should be able to decrypt it in the same way.

The starter code for rot13 is rot13.cpp which is mostly an empty shell. You will need to provide the file I/O and the functions that implements the rot13 algorithm. Note: rot13 is very specific version of the Caesar cipher.

The rot13 algorithm just simply rotates each individual alphabetic character by 13 characters. It leaves the numbers, punctuation, etc alone. To encrypt you just rotate each character by 13 characters. To decrypt you just rotate (in either direction) the characters by 13 as well. Please preserve the case of the rotated letter.

You may want to convert all lowercase to uppercase characters before performing math on them to avoid overflows. You will want to convert them back to lowercase when done.

Example 1:

Given the letter a the encrypted letter becomes a + 13 = 110 or n

Given encrypted letter n than n + 13 (or 123) is greater than z so it wraps around (in this case back to a).

If using a char data type, the above would overflow and become a negative number. It is suggested that you convert lowercase characters to uppercase before performing the rotation and then convert back to lowercase.

Example 2:

Assuming your input file contains the following text:

The quick brown fox jumps over the moon!

Your encrypted file would be:

Gur dhvpx oebja sbk whzcf bire gur zbba!

Note: The decrypted text should be the same as the original file text.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions

Question

What is meant by convergence of U.S. GAAP and IFRS?

Answered: 1 week ago