Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void encode (string data,string Skey,string &CipherText)
- {
- byte key[16];
- byte iv[16];
- string theData,cipher;
- theData = data;
- string theKey(Skey);
- int i(0);
- theKey.append("t;rke;tlrke65409654ytr");
- while(i != 16)
- {
- key[i] = theKey[i];
- iv[i] = theKey[i];
- i++;
- }
- // Cipher Text Sink
- //string *CipherText = new string;
- // Encryptor
- CryptoPP::ECB_Mode< CryptoPP::AES >::Encryption
- //Encryptor( key, sizeof(key), iv );
- Encryptor( key, sizeof(key));
- // Encryption
- CryptoPP::StringSource( theData, true,
- new CryptoPP::StreamTransformationFilter( Encryptor,
- new CryptoPP::StringSink( cipher )
- ) // StreamTransformationFilter
- ); // StringSource
- CipherText = cipher;
- }
- void decode (string CT,string Skey,string &RText)
- {
- byte key[16];
- byte iv[16];
- string theKey(Skey);
- string cipher,text;
- cipher = CT;
- 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( cipher, true,
- new CryptoPP::StreamTransformationFilter( Decryptor,
- new CryptoPP::StringSink( text )
- ) // StreamTransformationFilter
- ); // StringSource
- }
- Error after error
- F:\C++ Code\cryptGUI\cryptGUI\Release>cryptGUI.exe
- Unhandled Exception: System.AccessViolationException: Attempted to read or write
- protected memory. This is often an indication that other memory is corrupt.
- at encode(basic_string<char\,std::char_traits<char>\,std::allocator<char> >*
- , basic_string<char\,std::char_traits<char>\,std::allocator<char> >* , basic_str
- ing<char\,std::char_traits<char>\,std::allocator<char> >* )
- at aesEncrypt(basic_string<char\,std::char_traits<char>\,std::allocator<char>
- >* , basic_string<char\,std::char_traits<char>\,std::allocator<char> >* data, b
- asic_string<char\,std::char_traits<char>\,std::allocator<char> >* key) in f:\c++
- code\cryptgui\cryptgui\cryptgui\drivercode.cpp:line 141
- at GUI.mainGUI.encode_Click(Object sender, EventArgs e) in f:\c++ code\cryptg
- ui\cryptgui\cryptgui\maingui.h:line 299
- at System.Windows.Forms.Control.OnClick(EventArgs e)
- at System.Windows.Forms.Button.OnClick(EventArgs e)
- at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
- at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, In
- t32 clicks)
- at System.Windows.Forms.Control.WndProc(Message& m)
- at System.Windows.Forms.ButtonBase.WndProc(Message& m)
- at System.Windows.Forms.Button.WndProc(Message& m)
- at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
- at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
- at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr
- wparam, IntPtr lparam)
- at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
- at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.Uns
- afeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int
- 32 reason, Int32 pvLoopData)
- at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 r
- eason, ApplicationContext context)
- at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason
- , ApplicationContext context)
- at System.Windows.Forms.Application.RunDialog(Form form)
- at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
- at System.Windows.Forms.Form.ShowDialog()
- at main() in f:\c++ code\cryptgui\cryptgui\cryptgui\maingui.cpp:line 13
- at _mainCRTStartup()
- F:\C++ Code\cryptGUI\cryptGUI\Release>
Advertisement
Add Comment
Please, Sign In to add comment