:) Hello,
I am making a C++ console application where the user can encrypt and decrypt text. So far, I have successfully made the encryption part, but am not quite sure how to make the decryption part. For example: abcb -> 128.70.88.70. but I can't make it go back to abcb. Here is my code so far:
#include <conio.h>
#include <stdio.h>
#include <cstdlib>
#include "windows.h"
#include "winuser.h"
#include <cmath>
#include <iostream>
#include <iomanip>
#include <complex>
#include <string>
int main ()
{
using namespace std;
int f;
char n;
char b;
char none;
string password;
string nonencr;
string encr;
system("color 1f");
cout <<"************************************************************************"; cout << endl;
cout <<"****************Welcome to Bashcode Encryptor© v1.0.0.0*****************"; cout << endl;
cout <<"************************************************************************"; cout << endl;
cout << endl;
cout << endl;
cout <<"Enter password: "; do{
n=char(getch());
if(int(n) !=13 && int(n) !=8){
cout<<"x";
password += n;
}
}while(int(n)!=13);
cout << endl;
cout << endl;
if ( password == "bashcode"){
cout <<"ACCESS GRANTED"; Sleep(1500); }
else {system("CLS"); cout <<"ACCESS DENIED. The program will now shut down."; Sleep(2000) ; return 0;}
cout << endl;
cout << endl;
system("CLS");
cout <<"Select an option:" << endl;
cout << endl;
cout <<"Encrypt (1)" << endl;
cout << endl;
cout <<"Decrypt (2)" << endl;
cout << endl;
cout <<">>>>>>>> "; cin >> f;
if (f == 1){
system("CLS"); cout <<"Input text to be encrypted: "; do{
none=char(getch());
if(int(none) == 97){
cout<<"a";
encr += "128.";
}
if(int(none) == 98){
cout<<"b";
encr += "70.";}
if(int(none) == 99){
cout<<"c";
encr += "88.";}
if(int(none) == 100){
cout<<"d";
encr += "40.";}
if(int(none) == 101){
cout<<"e";
encr += "54.";}
if(int(none) == 102){
cout<<"f";
encr += "36.";}
if(int(none) == 103){
cout<<"g";
encr += "10.";}
}while(int(none)!=13);
cout << endl;
cout << endl;
cout << "Encryped version: ";
cout << endl;
cout << endl;
cout << encr;
}
if (f == 2){
cout <<"Enter something to decrypt: ";
cout << endl;
cout << endl;
cout << nonencr;
}
cin.clear();
cin.ignore(255, '\n');
cin.get();
return 0;
}
I would greatly appreciate any help :icon_cheesygrin: