Purchase Solution

C++ program for variation of Caesar's substitution cipher

Not what you're looking for?

Ask Custom Question

The caeser cipher, which shifts all letters by a certain amount, is easy to decipher. Try this, instead of numbers use letters. Consider this, the word is FEATHER. Remove duplicate letters, making FEATHR, and append the rest of the letters of the alphabet in reverse order.
Now encrypt the letters as follows:
Now, write a program that encrypts or decrypts a file using this cipher.

For example,
crypt -d -kFEATHER encrypt.txt output.txt
decrypts a file using the keyword FEATHER. You must always supply a keyword.

This is what I have so far:

#include <iostream>
#include <fstream>
#include <string>

using namespace std;
string rem_Duplicate(string str1)
{
string str2;
int pos;
for (int i = 0; i < str1.length(); i++)
{
if ((pos = str2.find(str1[i])) < 0)
str2 += str1[i];
}
cout << str2 << endl;
return str2;
}

int main()
{
ofstream output_file;
ifstream input_file("output.txt");
output_file.open("input.txt");
string FEATHER;
string key = FEATHER;
cout << "Enter the Key: ";
cin >> key;
key = rem_Duplicate(key);

input_file.close();
output_file.close();

cin.clear();
cin.ignore();
cin.get();

return 0;
}

Thank you for your time.

Purchase this Solution

Solution Summary

Solution checks for validity of the arguments provided at the command line. It transforms only the alphabets in the input file while retaining their (upper/lower) case.

Solution Preview

Please find attached 597359.zip that contains following files:
- 597359.cpp
- input.txt
- encrypted.txt
- decrypted.txt

Code was tested using g++ compiler version ...

Purchase this Solution


Free BrainMass Quizzes
Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Basic Networking Questions

This quiz consists of some basic networking questions.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.