Advertisement
HackerFail

Simple encrypt of words

Jun 25th, 2014
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.33 KB | None | 0 0
  1. cFuncs.h
  2.  
  3. // Credits to Hacker Fail for making the program and change the func
  4. // Credits to Code64 for the func
  5.  
  6. #include <string.h>
  7. #include <windows.h>
  8. #include <iostream>
  9. #include <tchar.h>
  10. #include <fstream>
  11. #include <string>
  12.  
  13. char* Encrypt(const char *plaintext)
  14. {
  15.     int len = strlen(plaintext);
  16.     char *cyphertext = new char[len + 1];
  17.     for(int i = 0; i < len; i++)
  18.         cyphertext[i] = plaintext[i] + 4;
  19.  
  20.     cyphertext[len] = 0;
  21.     return cyphertext;
  22. }
  23.  
  24.  
  25. cMain.cpp
  26.  
  27. // Credits to Hacker Fail for making the program and change the func
  28. // Credits to Code64 for the func
  29.  
  30. #include "cFuncs.h"
  31.  
  32. using namespace std;
  33.  
  34. class Comando
  35. {
  36. public :
  37.  
  38.     char pa[999];
  39.  
  40.     int e;
  41.  
  42.     void Crip();
  43. };
  44.  
  45. void Comando::Crip()
  46. {
  47.  
  48.     ofstream out;
  49.  
  50.     out.open("Encrypted words.txt");
  51.  
  52.     out << "Words encrypted :\n";
  53.  
  54.     Comando use;
  55.  
  56.     while(true)
  57.     {
  58.         cout << "\nEnter the word to be encrypted :\n\n";
  59.         cin >> use.pa;
  60.        
  61.         cout << "\n\nThe word encrypted : " << Encrypt(use.pa) << "\n\n";
  62.        
  63.         out << use.pa << " = " << Encrypt(use.pa) << "\n";
  64.  
  65.         Sleep(500);
  66.  
  67.         cout << "Do you want to use the program again?\n"
  68.             << "1 -> Yes\n"
  69.             << "2 -> No\n\n";
  70.         cin >> use.e;
  71.  
  72.         if ( use.e == 1 )
  73.         {
  74.             cout << "\n\nThanks you for using the program again!\n\n";
  75.         } else if ( use.e == 2 )
  76.         {
  77.             cout << "\n\nThanks for using the program!\n\n";
  78.             Sleep(500);
  79.             exit(0);
  80.         } else if ( use.e != 1 && use.e != 2 )
  81.         {
  82.             cout << "\n\nEnter a valid option... The program will close...\n";
  83.             Sleep(500);
  84.             exit (0);
  85.         }
  86.     }
  87.  
  88.     out.close();
  89. }
  90.  
  91. int main()
  92. {
  93.     Comando use;
  94.  
  95.     ofstream out;
  96.  
  97.     out.open("Encrypt.h");
  98.  
  99.     out << "//Func made by Code64"
  100.         << "\n//Program made by HackerFail\n\n\n\n\n"
  101.         << "char* Decrypt(const char *plaintext)"
  102.          << "\n{"
  103.          << "\n int len = strlen(plaintext);"
  104.          << "\n char *cyphertext = new char[len + 1];"
  105.          << "\n for(int i = 0; i < len; i++)"
  106.          << "\n cyphertext[i] = plaintext[i] - 4;"
  107.          << "\n cyphertext[len] = 0;"
  108.          << "\n return cyphertext;"
  109.          << "\n}";
  110.  
  111.     out.close();
  112.  
  113.     system ("title Encrypt made by HackerFail"); // title of the program
  114.        
  115.     system("color 72"); // color of the program
  116.        
  117.     cout << "Program started : ";
  118.     system("TIME /t");
  119.  
  120.     cout << "\n\nDont use the space!!\n\n";
  121.  
  122.     use.Crip();
  123.  
  124.     system("pause");
  125.  
  126.     return 0;
  127.  
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement