//ROT13 Encryption
//By ~DreamVB~

#include <iostream>

using namespace std;
using std::cout;
using std::endl;

string Rot13(string s){
	int i = 0;
	string s_buffer = "";
	unsigned char c = '\0';

	while(i <=s.length()){
		//Get char
		c = s[i];
		//Check lowercase letters.
		if (islower(c)){
			c += 13;
			if (c > 'z'){
				c-= 26;
			}
		}

		//Check uppercase letters.
		if (isupper(c)){
			c += 13;
			if (c > 'Z'){
				c-=26;
			}
		}
		//Build string
		s_buffer += c;
		//INC counter
		i++;
	}
	//Return string
	return s_buffer;
}

int main(int argc, char *argv[]){
	string s_test = "This is an example of ROT13 in C++";
	string s0 = "";

	//Encrypt
	s0 = Rot13(s_test);

	cout << "Original      : " << s_test.c_str() << endl;
	cout << "Encrypted     : " << s0.c_str() << endl;
	//Decrypt
	s0 = Rot13(s0);

	cout << "Decrypted     : " << s0.c_str() << endl;

	//Clear up
	s0.clear();
	s_test.clear();

	system("pause");
	return 0;
}