Please help on my HW Homework 10 For the homework youre give
Please help on my HW
Homework 10
For the homework you’re given an encoded text file. Download it from Titanium. Your goal is to write a program that can encode and decode text files. Try to find the hidden message! Decode the hidden message.
The cryptography we’ll be using is a Rot13 or a rotate by 13 places. Also known as a Cesar cypher. There are 26 letters in the alphabet, by rotating 13 places the key is it’s own inverse. Encoding is the same as decoding. Take a look below
Taken from Wikipedia. Benjamin D. Esham (bdesham)
Your program should open up a file convert the file line by line, either encoding or decoding (the same process for both). Don’t worry about spaces or punctuation, you only need to worry about lowercase and uppercase letters. Comment what the decoded message is in your source code and submit that as your homework.
OrFherGbQevaxLbheBinygvar
Solution
string(data) already present in text file
read the string until null is not find
/*
n is 13
encryption:
x+n mod 26
decryption
x-n mod 26
uppercase(A-Z) 65 to 91
lowercase (a-z) 97 to 122
*/
#include<iostream>
#include<fstream>
#include<math.h>
using namespace std;
int main()
{
ofstream file;
file.open(\"logic.txt\");
char ch[100],temp;
int i=0;
file<<\"the encrypt data:\ \";
while(ch[i] != NULL)
{
ch1[i]=((ch[i]+13)%26);
file<<temp;
i++;
}
file<<\"\ \"<<\"the decrypt data:\";
while(ch1[i] != NULL)
{
temp=((ch1[i]-13)%26);
file<<temp;
i++;
}
