Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <iostream>
- #include <fstream>
- #include <stdio.h>
- #include <string>
- #include "stdafx.h"
- #include<stdio.h>
- #include "stdafx.h"
- #include <iostream>
- #include <iomanip>
- #define CRYPTOPP_DEFAULT_NO_DLL
- #include "dll.h"
- using namespace std;
- byte key[CryptoPP::AES::DEFAULT_KEYLENGTH], iv[CryptoPP::AES::BLOCKSIZE];
- std::string ciphertext, decryptedtext, encoded;
- void AES_CBC()
- {
- ciphertext = "";
- decryptedtext = "";
- encoded = "";
- /*CryptoPP::AES::Encryption aesEncryption(key, CryptoPP::AES::DEFAULT_KEYLENGTH);
- CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcEncryption(aesEncryption, iv);
- CryptoPP::StreamTransformationFilter stfEncryptor(cbcEncryption, new CryptoPP::StringSink(ciphertext));
- stfEncryptor.Put(reinterpret_cast<const unsigned char*>(plaintext.c_str()), plaintext.length() + 1);
- stfEncryptor.MessageEnd();*/
- cout << "AES_CBC Cipher Text: " << std::endl;
- for (int i = 0; i < ciphertext.size(); i++) {
- cout << "0x" << std::hex << (0xFF & static_cast<byte>(ciphertext[i])) << " ";
- }
- cout << std::endl << std::endl;
- CryptoPP::AES::Decryption aesDecryption(key, CryptoPP::AES::DEFAULT_KEYLENGTH);
- CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption(aesDecryption, iv);
- CryptoPP::StreamTransformationFilter stfDecryptor(cbcDecryption, new CryptoPP::StringSink(decryptedtext));
- stfDecryptor.Put(reinterpret_cast<const unsigned char*>(ciphertext.c_str()), ciphertext.size());
- stfDecryptor.MessageEnd();
- cout << "AES-CBC Decrypted Text: " << std::endl << decryptedtext;
- cout << std::endl << std::endl;
- }
- int main()
- {
- memset(key, 0x00, CryptoPP::AES::DEFAULT_KEYLENGTH);
- memset(iv, 0x00, CryptoPP::AES::BLOCKSIZE);
- cout << "Cipher Text: " << std::endl;
- cout << ciphertext;
- cout << std::endl << std::endl;
- AES_CBC();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement