#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
string decrypt;
string encrypt;
int main()
{
char choice;
{
//Elegir, encriptar o decriptar
cout<<"\\**Bienvenido al programa de Decriptacion/Encriptacion de Enrique Silvela**// \n";
cout<<"___________________________________________________________ ___________________ \n";
cout<<"****************************************************************************** \n";
cout<<"****************************************************************************** \n";
cout<<"****************************************************************************** \n";
cout<<"****************************************************************************** \n";
cout<<endl;
cout<<endl;
inicio:
cout<<"Elige que quieres hacer: Decriptar o Encriptar (D para Decriptar y E para encriptar): \n";
cin>>choice;
if (choice = 'D')
{
cout<<"Ahora selecciona la palabra que quieres decriptar(Usa _ para los espacios): \n";
decrypt;
}
else if (choice = 'E')
{
cout<<"Ahora escribe la palabra que quieres encriptar (Usa _ para los espacios): \n";
encrypt;
}
else
{
cout<<"Seleccion erronea, vuelve a intentarlo: \n";
goto inicio;
}
}
encrypt;
{
string wordu;
cin>>wordu;
string str (wordu);
size_t found;
found=str.find_first_of("a");
while (found!=string::npos)
{
str[found] = 'z';
found=str.find_first_of("a",found+1);
}
found=str.find_first_of("b");
while (found!=string::npos)
{
str[found] = 'y';
found=str.find_first_of("b",found+1);
}
found=str.find_first_of("c");
while (found!=string::npos)
{
str[found] = 'x';
found=str.find_first_of("c",found+1);
}
found=str.find_first_of("d");
while (found!=string::npos)
{
str[found] = 'w';
found=str.find_first_of("d",found+1);
}
found=str.find_first_of("e");
while (found!=string::npos)
{
str[found] = 'v';
found=str.find_first_of("e",found+1);
}
found=str.find_first_of("f");
while (found!=string::npos)
{
str[found] = 'u';
found=str.find_first_of("f",found+1);
}
found=str.find_first_of("g");
while (found!=string::npos)
{
str[found] = 't';
found=str.find_first_of("g",found+1);
}
found=str.find_first_of("h");
while (found!=string::npos)
{
str[found] = 's';
found=str.find_first_of("h",found+1);
}
found=str.find_first_of("i");
while (found!=string::npos)
{
str[found] = 'r';
found=str.find_first_of("i",found+1);
}
found=str.find_first_of("j");
while (found!=string::npos)
{
str[found] = 'q';
found=str.find_first_of("j",found+1);
}
found=str.find_first_of("k");
while (found!=string::npos)
{
str[found] = 'p';
found=str.find_first_of("k",found+1);
}
found=str.find_first_of("l");
while (found!=string::npos)
{
str[found] = 'o';
found=str.find_first_of("l",found+1);
}
found=str.find_first_of("m");
while (found!=string::npos)
{
str[found] = 'n';
found=str.find_first_of("m",found+1);
}
found=str.find_first_of("n");
while (found!=string::npos)
{
str[found] = 'm';
found=str.find_first_of("n",found+1);
}
found=str.find_first_of("o");
while (found!=string::npos)
{
str[found] = 'l';
found=str.find_first_of("o",found+1);
}
found=str.find_first_of("p");
while (found!=string::npos)
{
str[found] = 'q';
found=str.find_first_of("p",found+1);
}
found=str.find_first_of("q");
while (found!=string::npos)
{
str[found] = 'j';
found=str.find_first_of("q",found+1);
}
found=str.find_first_of("r");
while (found!=string::npos)
{
str[found] = 'i';
found=str.find_first_of("r",found+1);
}
found=str.find_first_of("s");
while (found!=string::npos)
{
str[found] = 'h';
found=str.find_first_of("s",found+1);
}
found=str.find_first_of("t");
while (found!=string::npos)
{
str[found] = 'g';
found=str.find_first_of("t",found+1);
}
found=str.find_first_of("u");
while (found!=string::npos)
{
str[found] = 'f';
found=str.find_first_of("u",found+1);
}
found=str.find_first_of("v");
while (found!=string::npos)
{
str[found] = 'e';
found=str.find_first_of("v",found+1);
}
found=str.find_first_of("w");
while (found!=string::npos)
{
str[found] = 'd';
found=str.find_first_of("w",found+1);
}
found=str.find_first_of("x");
while (found!=string::npos)
{
str[found] = 'c';
found=str.find_first_of("x",found+1);
}
found=str.find_first_of("y");
while (found!=string::npos)
{
str[found] = 'b';
found=str.find_first_of("y",found+1);
}
found=str.find_first_of("z");
while (found!=string::npos)
{
str[found] = 'a';
found=str.find_first_of("z",found+1);
} cout << str << endl;
}
char reintentar;
{
cout<<"Quieres volver a intentarlo? ('S' si y 'N' no): \n";
reintentar:
cin>>reintentar;
}
char select;
{
if (reintentar == 'S'||'s');
choice;
}
decrypt;
{
string worda;
cin>>worda;
string str (worda);
size_t found;
found=str.find_first_of("a");
while (found!=string::npos)
found=str.find_first_of("n");
while (found!=string::npos)
{
str[found] = 'm';
found=str.find_first_of("n",found+1);
}
found=str.find_first_of("o");
while (found!=string::npos)
{
str[found] = 'l';
found=str.find_first_of("o",found+1);
}
found=str.find_first_of("p");
while (found!=string::npos)
{
str[found] = 'q';
found=str.find_first_of("p",found+1);
}
found=str.find_first_of("q");
while (found!=string::npos)
{
str[found] = 'j';
found=str.find_first_of("q",found+1);
}
found=str.find_first_of("r");
while (found!=string::npos)
{
str[found] = 'i';
found=str.find_first_of("r",found+1);
}
found=str.find_first_of("s");
while (found!=string::npos)
{
str[found] = 'h';
found=str.find_first_of("s",found+1);
}
found=str.find_first_of("t");
while (found!=string::npos)
{
str[found] = 'g';
found=str.find_first_of("t",found+1);
}
found=str.find_first_of("u");
while (found!=string::npos)
{
str[found] = 'f';
found=str.find_first_of("u",found+1);
}
found=str.find_first_of("v");
while (found!=string::npos)
{
str[found] = 'e';
found=str.find_first_of("v",found+1);
}
found=str.find_first_of("w");
while (found!=string::npos)
{
str[found] = 'd';
found=str.find_first_of("w",found+1);
}
found=str.find_first_of("x");
while (found!=string::npos)
{
str[found] = 'c';
found=str.find_first_of("x",found+1);
}
found=str.find_first_of("y");
while (found!=string::npos)
{
str[found] = 'b';
found=str.find_first_of("y",found+1);
}
found=str.find_first_of("z");
while (found!=string::npos)
{
str[found] = 'a';
found=str.find_first_of("z",found+1);
{
str[found] = 'z';
found=str.find_first_of("a",found+1);
}
found=str.find_first_of("b");
while (found!=string::npos)
{
str[found] = 'y';
found=str.find_first_of("b",found+1);
}
found=str.find_first_of("c");
while (found!=string::npos)
{
str[found] = 'x';
found=str.find_first_of("c",found+1);
}
found=str.find_first_of("d");
while (found!=string::npos)
{
str[found] = 'w';
found=str.find_first_of("d",found+1);
}
found=str.find_first_of("e");
while (found!=string::npos)
{
str[found] = 'v';
found=str.find_first_of("e",found+1);
}
found=str.find_first_of("f");
while (found!=string::npos)
{
str[found] = 'u';
found=str.find_first_of("f",found+1);
}
found=str.find_first_of("g");
while (found!=string::npos)
{
str[found] = 't';
found=str.find_first_of("g",found+1);
}
found=str.find_first_of("h");
while (found!=string::npos)
{
str[found] = 's';
found=str.find_first_of("h",found+1);
}
found=str.find_first_of("i");
while (found!=string::npos)
{
str[found] = 'r';
found=str.find_first_of("i",found+1);
}
found=str.find_first_of("j");
while (found!=string::npos)
{
str[found] = 'q';
found=str.find_first_of("j",found+1);
}
found=str.find_first_of("k");
while (found!=string::npos)
{
str[found] = 'p';
found=str.find_first_of("k",found+1);
}
found=str.find_first_of("l");
while (found!=string::npos)
{
str[found] = 'o';
found=str.find_first_of("l",found+1);
}
found=str.find_first_of("m");
while (found!=string::npos)
{
str[found] = 'n';
found=str.find_first_of("m",found+1);
}
} cout << str << endl;
}
reintentar;
return 0;
}