Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <stdio.h>
- #include <stdlib.h>
- #include <iostream>
- #include <string>
- using namespace std;
- const int SHIFT = 3;
- string doEncrypt( string plainText );
- string doDecrypt( string encryptedText );
- int main()
- {
- cout << "Learning Project #3: Caesar Chiper" << endl;
- string textToEncrypt = "the quick brown fox jumps over the lazy dog";
- cout << "Text to Encrypt: " << textToEncrypt << endl;
- string textEncrypted = doEncrypt( textToEncrypt );
- cout << "Encrypted Text: " << textEncrypted << endl;
- string textDecrypted = doDecrypt(textEncrypted);
- cout << "Decrypted Text: " << textDecrypted << endl;
- // Bad form, so sue me.
- system("PAUSE");
- return 1;
- }
- string doEncrypt( string plainText )
- {
- string encryptedText = "";
- for( unsigned int i = 0; i < plainText.length(); i++ )
- {
- int temp1 = int(plainText[i]) + SHIFT;
- char temp2 = char(temp1);
- encryptedText += temp2;
- }
- return encryptedText;
- }
- string doDecrypt( string plainText )
- {
- string decryptedText = "";
- for( unsigned int i = 0; i < plainText.length(); i++ )
- {
- int temp1 = int(plainText[i]) - SHIFT;
- char temp2 = char(temp1);
- decryptedText += temp2;
- }
- return decryptedText;
- }
Add Comment
Please, Sign In to add comment