Advertisement
Guest User

Untitled

a guest
May 24th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. #include <windows.h>
  2. #include <iostream>
  3. #include <fstream>
  4. #include <stdio.h>
  5. #include <string>
  6. #include "stdafx.h"
  7. #include<stdio.h>
  8. #include "stdafx.h"
  9. #include <iostream>
  10. #include <iomanip>
  11.  
  12.  
  13. #define CRYPTOPP_DEFAULT_NO_DLL
  14. #include "dll.h"
  15.  
  16. using namespace std;
  17.  
  18. byte key[CryptoPP::AES::DEFAULT_KEYLENGTH], iv[CryptoPP::AES::BLOCKSIZE];
  19. std::string ciphertext, decryptedtext, encoded;
  20.  
  21.  
  22. void AES_CBC()
  23. {
  24. ciphertext = "";
  25. decryptedtext = "";
  26. encoded = "";
  27.  
  28. /*CryptoPP::AES::Encryption aesEncryption(key, CryptoPP::AES::DEFAULT_KEYLENGTH);
  29. CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcEncryption(aesEncryption, iv);
  30. CryptoPP::StreamTransformationFilter stfEncryptor(cbcEncryption, new CryptoPP::StringSink(ciphertext));
  31. stfEncryptor.Put(reinterpret_cast<const unsigned char*>(plaintext.c_str()), plaintext.length() + 1);
  32. stfEncryptor.MessageEnd();*/
  33.  
  34. cout << "AES_CBC Cipher Text: " << std::endl;
  35.  
  36. for (int i = 0; i < ciphertext.size(); i++) {
  37. cout << "0x" << std::hex << (0xFF & static_cast<byte>(ciphertext[i])) << " ";
  38. }
  39. cout << std::endl << std::endl;
  40.  
  41. CryptoPP::AES::Decryption aesDecryption(key, CryptoPP::AES::DEFAULT_KEYLENGTH);
  42. CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption(aesDecryption, iv);
  43. CryptoPP::StreamTransformationFilter stfDecryptor(cbcDecryption, new CryptoPP::StringSink(decryptedtext));
  44. stfDecryptor.Put(reinterpret_cast<const unsigned char*>(ciphertext.c_str()), ciphertext.size());
  45. stfDecryptor.MessageEnd();
  46. cout << "AES-CBC Decrypted Text: " << std::endl << decryptedtext;
  47. cout << std::endl << std::endl;
  48. }
  49.  
  50.  
  51.  
  52. int main()
  53. {
  54.  
  55. memset(key, 0x00, CryptoPP::AES::DEFAULT_KEYLENGTH);
  56. memset(iv, 0x00, CryptoPP::AES::BLOCKSIZE);
  57.  
  58. cout << "Cipher Text: " << std::endl;
  59. cout << ciphertext;
  60. cout << std::endl << std::endl;
  61.  
  62. AES_CBC();
  63.  
  64.  
  65.  
  66.  
  67. system("pause");
  68. return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement