rendered paste body#include <iostream>#include <cstring>#include <cstdlib>#include <ctime>#include <string>#include <sstream>using namespace std;using std::string;#define DEFAULT_KEYS 3int cipher[100];string transCode(int KeyCount, string Message, int Encode){ unsigned int i; int Value, Key; string Result; for(i = 0; i < Message.length(); i++){ Value = Message[i]; Key = cipher[i % KeyCount]; if(Encode) Value = Value + Key; else Value = Value - Key; Result += Value; } return Result;}int main(int argc, char *argv[]){ int KeyCount; int CipherRange; int i; string KeyInput; string Message; // Defaults KeyInput = ""; Message = ""; KeyCount = -1; CipherRange = 10; // Randomize seed srand(time(NULL)); /* while(KeyCount < 1 || KeyCount > 10){ cout << "Number of keys [" << DEFAULT_KEYS << "]: "; cin >> KeyInput; cin.get(); if(KeyInput.compare("\n")){ KeyCount = DEFAULT_KEYS; continue; }else KeyCount = KeyInput; cout << KeyCount << endl; } */ KeyCount = DEFAULT_KEYS; cout << "String to encode: "; cin >> Message; cin.get(); cout << "Message = \"" << Message << "\"" << endl; // Generate keys for(i = 0; i < KeyCount; i++) cipher[i] = (int)rand()%CipherRange; string EncodedMessage = transCode(KeyCount, Message, 1); string DecodedMessage = transCode(KeyCount, EncodedMessage, 0); cout << "Original: " << Message << endl; cout << "Encoded : " << EncodedMessage << endl; cout << "Decoded : " << DecodedMessage << endl; return(0);}