Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include "stdafx.h"
- // Other Includes
- #include "adevlib.h"
- // Crypto++ Includes
- #include "lib/aes.h"
- #include "lib/modes.h"
- #include "lib/filters.h"
- using namespace std;
- using namespace CryptoPP;
- void encode (string data,string Skey,string &CipherText)
- {
- byte key[16];
- byte iv[16];
- string theKey(Skey);
- int i(0);
- theKey.append("t;rke;tlrke65409654ytr");
- while(i != 16)
- {
- key[i] = theKey[i];
- iv[i] = theKey[i];
- i++;
- }
- CipherText.append(" "); // Append
- // Encryptor
- CryptoPP::ECB_Mode< CryptoPP::AES >::Encryption
- //Encryptor( key, sizeof(key), iv );
- Encryptor( key, sizeof(key));
- // Encryption
- CryptoPP::StringSource( data, true,
- new CryptoPP::StreamTransformationFilter( Encryptor,
- new CryptoPP::StringSink( CipherText )
- ) // StreamTransformationFilter
- ); // StringSource
- }
- void decode (string CT,string Skey,string &RText)
- {
- byte key[16];
- byte iv[16];
- string theKey(Skey);
- int i(0);
- theKey.append("t;rke;tlrke65409654ytr");
- while(i != 16)
- {
- key[i] = theKey[i];
- iv[i] = theKey[i];
- i++;
- }
- // Decryptor
- CryptoPP::ECB_Mode< CryptoPP::AES >::Decryption
- // Decryptor( key, sizeof(key), iv );
- Decryptor( key, sizeof(key) );
- // Decryption
- CryptoPP::StringSource( CT, true,
- new CryptoPP::StreamTransformationFilter( Decryptor,
- new CryptoPP::StringSink( RText )
- ) // StreamTransformationFilter
- ); // StringSource
- }
- int main ()
- {
- int mode(0);
- cin >> mode;
- cin.get();
- string key;
- cout << "Put a fucking key in" << endl;
- getline(cin,key);
- string key2;
- cout << "Enter it again to make sure it is right" << endl;
- getline(cin,key2);
- if(key != key2)
- {
- return 0;
- }
- string name;
- cout << "Put in a fucking file name cunt" << endl;
- getline(cin,name);
- if(mode == 0)
- {
- string *data = new string;
- string *out = new string;
- readAllDataFromFile(name,*data);
- encode(*data,key,*out);
- delete(data);
- cout << "Please enter your out name" << endl;
- getline(cin,name);
- //base64_encode(*out,*out);
- writeDataToFile(name,*out);
- delete(out);
- }
- if(mode == 1)
- {
- string *dataz = new string;
- string *outz = new string;
- readAllDataFromFile(name,*dataz);
- //base64_decode(*dataz,*dataz);
- decode(*dataz,key,*outz);
- delete(dataz);
- cout << "Please enter your out name" << endl;
- getline(cin,name);
- writeDataToFile(name,*outz);
- delete(outz);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment