I've been working on a GUI that uses Crypto++. After a few hours of messing 
around I was able to make the linker work correctly using a .lib file.
However I ran into an issue that really made me hit a brick wall and 
confused me. 

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
> }
>
I have used this code in a console application and it works fine with 
really no errors. However once I started windows forms I got a set of 
bloody errors that literally meant nothing to me.
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>
I've heard that this error is because of a bug in Crypto++ either way I 
don't know how to fix it. So if anyone has ideas than or a fix to the issue 
then I would grateful for that. 

http://www.mediafire.com/download/8curwfrlvxlpf0p/cryptGUI.zip

-- 
-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
--- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to