Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- char encrypt()
- {
- cout << "Welcome to the amazing world of encrypting!\n" << "Please enter the text you want to encrypt: ";
- string input_text;
- string encrypted_text;
- while (cin.get() != '\n'); getline(cin, input_text); cout << endl;
- int length = input_text.length();
- for(int i = 0; i < length; i++) // input_text[i]; to check the letter that's going through the for loop
- {
- int input_text_number = input_text[i];
- /*cout << input_text_number << " "; // This is a test for the number of the letter in the loop
- */
- int encrypted_number = input_text_number + 1;
- encrypted_text = encrypted_number;
- cout << encrypted_text;
- }
- cout << endl;
- return 0;
- }
- char decrypt()
- {
- cout << "Welcome to the amazing world of decrypting!\n" << "Please enter the text you want to decrypt: ";
- string input_text_decrypted;
- string decrypted_text;
- while (cin.get() != '\n'); getline(cin, input_text_decrypted); cout << endl;
- int length_decrypted = input_text_decrypted.length();
- for(int o = 0; o < length_decrypted; o++)
- {
- int input_text_decrypted_number = input_text_decrypted[o];
- int decrypted_number = input_text_decrypted_number - 1;
- decrypted_text = decrypted_number;
- cout << decrypted_text;
- }
- cout << endl;
- return 0;
- }
- int main()
- {
- system("TITLE Crypt-o-matic");
- int enc_or_dec;
- cout << "Welcome to the Crypt-o-matic! Would you like to encrypt (0), or decrypt(1)?" << endl;
- cin >> enc_or_dec;
- if(enc_or_dec == 0) // To encrypt
- {
- encrypt();
- }
- if(enc_or_dec == 1) // To decrypt
- {
- decrypt();
- }
- system("PAUSE");
- return 0;
- }
Add Comment
Please, Sign In to add comment