Results 1 to 15 of 15

Thread: Compiling & using Crypto++ with mingw version of Qt

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    May 2009
    Posts
    147
    Thanks
    11
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Compiling & using Crypto++ with mingw version of Qt

    this is a function I wrote & tested for encrypting an in memory file stored in a QByteArray.
    it takes a QByteArray and a passPhrase and then encrypts the contents of the QByteArray.
    Crypto++ encryption class which it uses is DefaultEncryptorWithMAC and according to the reference doc it uses Password-Based Encryptor using DES-EDE2 and HMAC/SHA-1.

    Qt Code:
    1. void encrypt(QByteArray &in_out, const char *passPhrase) {
    2.  
    3. string tmp;
    4. StringSource s((const byte *)in_out.constData(), in_out.size(), true, new DefaultEncryptorWithMAC(passPhrase, new StringSink(tmp)));
    5. in_out.clear();
    6. in_out.append(QByteArray(tmp.c_str(), tmp.size()));
    7.  
    8. }
    To copy to clipboard, switch view to plain text mode 

    for decrypting u simply need to a DefaultDecryptorWithMAC instead of the DefaultEncryptorWithMAC:

    Qt Code:
    1. void decrypt(QByteArray &in_out, const char *passPhrase) {
    2.  
    3. string tmp;
    4. StringSource s((const byte *)in_out.constData(), in_out.size(), true, new DefaultDecryptorWithMAC(passPhrase, new StringSink(tmp)));
    5. in_out.clear();
    6. in_out.append(QByteArray(tmp.c_str(), tmp.size()));
    7.  
    8. }
    To copy to clipboard, switch view to plain text mode 

    I am new to Crypto++ (and to cryptography in general) and haven't read the entire crypto++'s reference; Any idea about a better code is welcome.
    Last edited by FS Lover; 11th March 2010 at 20:24.

Similar Threads

  1. Don't configure under vs command prompt when building gcc (mingw) version of qt
    By piotr.dobrogost in forum Installation and Deployment
    Replies: 4
    Last Post: 1st February 2011, 20:28
  2. Windows minGW g++ version 3.4.5
    By PUK_999 in forum Newbie
    Replies: 4
    Last Post: 21st August 2009, 22:38
  3. Replies: 2
    Last Post: 12th July 2009, 08:24
  4. using the qt 4.4.0 evaluation version with MinGw
    By dano in forum Installation and Deployment
    Replies: 4
    Last Post: 4th July 2008, 16:02
  5. Wich MinGW Version should i use for QT 4.4.0?
    By raphaelf in forum Installation and Deployment
    Replies: 3
    Last Post: 27th May 2008, 14:29

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.