need to symmetric encryption in qt app
I use Qt with mingw on Windows XP.
I tried QCA but it doesn't work with Qt (app compiles but gives fatal error when trying to execute it).
I tried a compiled version of crypto++ too but it has compiling problems (many undefined reference errors).
I don't know how to get these libs to work.
please tell me a quick and easy way. I need only a symmetric encryption to encrypt and decrypt a file.
Re: need to symmetric encryption in qt app
I can't believe that qca doesn't work with Qt applications. What is that fatal error that you get when executing your application?
1 Attachment(s)
Re: need to symmetric encryption in qt app
Quote:
Originally Posted by
lyuts
I can't believe that qca doesn't work with Qt applications. What is that fatal error that you get when executing your application?
Code:
#include <QtCrypto>
#include <QtDebug>
#include <stdio.h>
#include <QApplication>
int main(int argc, char **argv)
{
char ca[1024]="abcdefg";
if(!QCA::isSupported("sha1")) printf("SHA1 not supported!\n");
else printf("SHA1 supported.\n");
QCA::Hash shaHash("sha1");
qDebug()<<shaHash.type();
shaHash.update(ca, 7);
return app.exec();
}
Code:
######################################################################
# Automatically generated by qmake (2.01a) ??*???? 16. ???? 23:25:30 2010
######################################################################
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
SOURCES += main.cpp
CONFIG+=crypto
CONFIG+=console
it compiles but says that SHA1 is not supported.
but QCA web site says: QCA has built-in support for the SHA1 and MD5 hash algorithms, and a weak random number source.
then I get a Windows error:
Attachment 4386
Re: need to symmetric encryption in qt app
Did you do ?
Or maybe use QCA Initializer.
Re: need to symmetric encryption in qt app
thanks lyuts.
I tested that adding QCA::init(); and QCA::Initializer I; at the begining of my program.
now it says SHA1 supported. but I still get Windows error.
Re: need to symmetric encryption in qt app
Run your program under GDB then and it'll tell you where the error is.
Re: need to symmetric encryption in qt app
Quote:
Originally Posted by
fatjuicymole
Run your program under GDB then and it'll tell you where the error is.
Code:
(gdb) run
Starting program: C:\Documents and Settings\xx\Desktop\qca\test\aes/debug\t.exe
[New thread 2824.0x1a4]
SHA1 supported.
Program received signal SIGSEGV, Segmentation fault.
0x10039c99 in qca2!_ZNK3QCA6Base642okEv () from f:\Qt2009.05\qt\bin\qca2.dll
(gdb)
what now?
Re: need to symmetric encryption in qt app
Try 'backtrace' command in gdb.
Re: need to symmetric encryption in qt app
Quote:
#0 0x10039c99 in qca2!_ZNK3QCA6Base642okEv ()
from f:\Qt2009.05\qt\bin\qca2.dll
#1 0x10026c77 in qca2!_ZN3QCA10hexToArrayERK7QString ()
from f:\Qt2009.05\qt\bin\qca2.dll
#2 0x1002afc5 in qca2!_ZN3QCA9Algorithm6changeERK7QStringS3_ ()
from f:\Qt2009.05\qt\bin\qca2.dll
#3 0x1002b14e in qca2!_ZN3QCA9AlgorithmC2ERK7QStringS3_ ()
from f:\Qt2009.05\qt\bin\qca2.dll
#4 0x1003fd50 in qca2!_ZN3QCA4HashC1ERK7QStringS3_ ()
from f:\Qt2009.05\qt\bin\qca2.dll
#5 0x004014bd in main (argc=1, argv=0x3d4d88) at main.cpp:18
line 18 is: QCA::Hash shaHash("sha1");
it seems that error is internal to qca2.dll. ?
Re: need to symmetric encryption in qt app
Well, it might be qca2.dll's fault by maybe you are providing invalid input that make it crash. Could you paste the complete source code you compiling and running?
Re: need to symmetric encryption in qt app
main.cpp
Code:
#include <QtCrypto>
#include <QtDebug>
#include <stdio.h>
#include <QApplication>
int main(int argc, char **argv)
{
QCA::init();
char ca[1024]="abcdefg";
if(!QCA::isSupported("md5")) printf("SHA1 not supported!\n");
else printf("SHA1 supported.\n");
QCA::Hash shaHash("sha1");
qDebug()<<shaHash.type();
shaHash.update(ca, 7);
return app.exec();
}
.pro
Code:
######################################################################
# Automatically generated by qmake (2.01a) ??*???? 16. ???? 23:25:30 2010
######################################################################
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
SOURCES += main.cpp
CONFIG+=crypto
CONFIG+=console
Re: need to symmetric encryption in qt app
Try to make ca a null terminated string and call
Code:
shaHash.update(ca);
instead of
Code:
shaHash.update(ca, 7);
Re: need to symmetric encryption in qt app