thenuke321

Untitled

May 4th, 2015
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.05 KB | None | 0 0
  1.     void encode (string data,string Skey,string &CipherText)
  2.     {
  3.         byte key[16];
  4.         byte iv[16];
  5.         string theData,cipher;
  6.         theData = data;
  7.         string theKey(Skey);
  8.         int i(0);
  9.         theKey.append("t;rke;tlrke65409654ytr");
  10.         while(i != 16)
  11.         {
  12.             key[i] = theKey[i];
  13.             iv[i] = theKey[i];
  14.             i++;
  15.         }
  16.         // Cipher Text Sink
  17.         //string *CipherText = new string;
  18.      
  19.         // Encryptor
  20.         CryptoPP::ECB_Mode< CryptoPP::AES >::Encryption
  21.         //Encryptor( key, sizeof(key), iv );
  22.         Encryptor( key, sizeof(key));
  23.      
  24.       // Encryption
  25.       CryptoPP::StringSource( theData, true,
  26.         new CryptoPP::StreamTransformationFilter( Encryptor,
  27.           new CryptoPP::StringSink( cipher )
  28.         ) // StreamTransformationFilter
  29.       ); // StringSource
  30.       CipherText = cipher;
  31.     }
  32.  
  33.     void decode (string CT,string Skey,string &RText)
  34.     {
  35.         byte key[16];
  36.         byte iv[16];
  37.         string theKey(Skey);
  38.         string cipher,text;
  39.         cipher = CT;
  40.        
  41.         int i(0);
  42.         theKey.append("t;rke;tlrke65409654ytr");
  43.         while(i != 16)
  44.         {
  45.             key[i] = theKey[i];
  46.             iv[i] = theKey[i];
  47.             i++;
  48.         }
  49.         // Decryptor
  50.         CryptoPP::ECB_Mode< CryptoPP::AES >::Decryption
  51.         // Decryptor( key, sizeof(key), iv );
  52.         Decryptor( key, sizeof(key) );
  53.      
  54.       // Decryption
  55.       CryptoPP::StringSource( cipher, true,
  56.         new CryptoPP::StreamTransformationFilter( Decryptor,
  57.           new CryptoPP::StringSink( text )
  58.         ) // StreamTransformationFilter
  59.       ); // StringSource
  60.     }
  61.  
  62. Error after error
  63. F:\C++ Code\cryptGUI\cryptGUI\Release>cryptGUI.exe
  64.  
  65. Unhandled Exception: System.AccessViolationException: Attempted to read or write
  66.  protected memory. This is often an indication that other memory is corrupt.
  67.    at encode(basic_string<char\,std::char_traits<char>\,std::allocator<char> >*
  68. , basic_string<char\,std::char_traits<char>\,std::allocator<char> >* , basic_str
  69. ing<char\,std::char_traits<char>\,std::allocator<char> >* )
  70.    at aesEncrypt(basic_string<char\,std::char_traits<char>\,std::allocator<char>
  71.  >* , basic_string<char\,std::char_traits<char>\,std::allocator<char> >* data, b
  72. asic_string<char\,std::char_traits<char>\,std::allocator<char> >* key) in f:\c++
  73.  code\cryptgui\cryptgui\cryptgui\drivercode.cpp:line 141
  74.    at GUI.mainGUI.encode_Click(Object sender, EventArgs e) in f:\c++ code\cryptg
  75. ui\cryptgui\cryptgui\maingui.h:line 299
  76.    at System.Windows.Forms.Control.OnClick(EventArgs e)
  77.    at System.Windows.Forms.Button.OnClick(EventArgs e)
  78.    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
  79.    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, In
  80. t32 clicks)
  81.    at System.Windows.Forms.Control.WndProc(Message& m)
  82.    at System.Windows.Forms.ButtonBase.WndProc(Message& m)
  83.    at System.Windows.Forms.Button.WndProc(Message& m)
  84.    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
  85.    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
  86.    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr
  87. wparam, IntPtr lparam)
  88.    at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
  89.    at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.Uns
  90. afeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int
  91. 32 reason, Int32 pvLoopData)
  92.    at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 r
  93. eason, ApplicationContext context)
  94.    at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason
  95. , ApplicationContext context)
  96.    at System.Windows.Forms.Application.RunDialog(Form form)
  97.    at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
  98.    at System.Windows.Forms.Form.ShowDialog()
  99.    at main() in f:\c++ code\cryptgui\cryptgui\cryptgui\maingui.cpp:line 13
  100.    at _mainCRTStartup()
  101.  
  102. F:\C++ Code\cryptGUI\cryptGUI\Release>
Advertisement
Add Comment
Please, Sign In to add comment