Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* *AES en/decryption */
- /* *Using Crypto++ */
- #include <iostream>
- #include <osrng.h>
- #include <rsa.h>
- #include <files.h>
- #include <sstream>
- #include <modes.h>
- #include <aes.h>
- #include <cstring>
- using namespace CryptoPP;
- using std::stringstream;
- /* sDecryptedSharedSecret was taken from http://pastebin.com/7Jvaama1 */
- /* Initial Vector */
- byte IV[AES::BLOCKSIZE];
- memcpy(IV,sDecryptedSharedSecret.c_str(),16);
- /* De/Encryptor */
- CFB_Mode<AES>::Decryption AESDecryptor((byte*)sDecryptedSharedSecret.c_str(),(unsigned int)16,IV,1);
- CFB_Mode<AES>::Encryption AESEncryptor((byte*)sDecryptedSharedSecret.c_str(),(unsigned int)16,IV,1);
- /* Encrypt Data */
- string sSource("Fill me with data");
- string sTarget("");
- try {
- StringSource(sSource, true,
- new StreamTransformationFilter(AESEncryptor,
- new StringSink(sTarget)
- )
- );
- } catch (CryptoPP::Exception) {
- std::cout<<"Something went wrong\n";
- }
- /* Decrypt data */
- //same as above, just set AESEncryptor to AESDecryptor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement