thenuke321

Untitled

May 20th, 2015
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include "stdafx.h"
  4. // Other Includes
  5. #include "adevlib.h"
  6. // Crypto++ Includes
  7. #include "lib/aes.h"
  8. #include "lib/modes.h"      
  9. #include "lib/filters.h"    
  10.                          
  11. using namespace std;
  12. using namespace CryptoPP;
  13.  
  14. void encode (string data,string Skey,string &CipherText)
  15. {
  16.     byte key[16];
  17.     byte iv[16];
  18.    
  19.     string theKey(Skey);
  20.     int i(0);
  21.     theKey.append("t;rke;tlrke65409654ytr");
  22.  
  23.     while(i != 16)
  24.     {
  25.         key[i] = theKey[i];
  26.         iv[i] = theKey[i];
  27.         i++;
  28.     }
  29.     CipherText.append("                "); // Append
  30.     // Encryptor
  31.     CryptoPP::ECB_Mode< CryptoPP::AES >::Encryption
  32.     //Encryptor( key, sizeof(key), iv );
  33.     Encryptor( key, sizeof(key));
  34.  
  35.   // Encryption
  36.   CryptoPP::StringSource( data, true,
  37.     new CryptoPP::StreamTransformationFilter( Encryptor,
  38.       new CryptoPP::StringSink( CipherText )
  39.     ) // StreamTransformationFilter
  40.   ); // StringSource
  41.  
  42. }
  43.  
  44. void decode (string CT,string Skey,string &RText)
  45. {
  46.     byte key[16];
  47.     byte iv[16];
  48.     string theKey(Skey);
  49.    
  50.     int i(0);
  51.     theKey.append("t;rke;tlrke65409654ytr");
  52.     while(i != 16)
  53.     {
  54.         key[i] = theKey[i];
  55.         iv[i] = theKey[i];
  56.         i++;
  57.     }
  58.     // Decryptor
  59.     CryptoPP::ECB_Mode< CryptoPP::AES >::Decryption
  60.     // Decryptor( key, sizeof(key), iv );
  61.     Decryptor( key, sizeof(key) );
  62.  
  63.   // Decryption
  64.   CryptoPP::StringSource( CT, true,
  65.     new CryptoPP::StreamTransformationFilter( Decryptor,
  66.       new CryptoPP::StringSink( RText )
  67.     ) // StreamTransformationFilter
  68.   ); // StringSource
  69. }
  70.  
  71. int main ()
  72. {
  73.     int mode(0);
  74.     cin >> mode;
  75.     cin.get();
  76.     string key;
  77.     cout << "Put a fucking key in" << endl;
  78.     getline(cin,key);
  79.     string key2;
  80.     cout << "Enter it again to make sure it is right" << endl;
  81.     getline(cin,key2);
  82.     if(key != key2)
  83.     {
  84.         return 0;
  85.     }
  86.     string name;
  87.     cout << "Put in a fucking file name cunt" << endl;
  88.     getline(cin,name);
  89.     if(mode == 0)
  90.     {
  91.         string *data = new string;
  92.         string *out = new string;
  93.         readAllDataFromFile(name,*data);
  94.         encode(*data,key,*out);
  95.         delete(data);
  96.         cout << "Please enter your out name" << endl;
  97.         getline(cin,name);
  98.         //base64_encode(*out,*out);
  99.         writeDataToFile(name,*out);
  100.         delete(out);
  101.     }
  102.     if(mode == 1)
  103.     {
  104.         string *dataz = new string;
  105.         string *outz = new string;
  106.         readAllDataFromFile(name,*dataz);
  107.         //base64_decode(*dataz,*dataz);
  108.         decode(*dataz,key,*outz);
  109.         delete(dataz);
  110.         cout << "Please enter your out name" << endl;
  111.         getline(cin,name);
  112.         writeDataToFile(name,*outz);
  113.         delete(outz);  
  114.     }
  115.     return 0;
  116. }
Advertisement
Add Comment
Please, Sign In to add comment