Posts Tagged 'c++'

Displaying numbers with qDebug

Following up on my last post about using qDebug to write logging information to a file, I’ve noticed that there is some confusion about how to best use qDebug.  qDebug is limited – it expects a QByteArray (or similar) because it is converting that directly into a char * string for output (about as simple as you can get).  However, most people want to write more information than just a simple byte array to the output stream.  Below are some examples:

//Basic qDebug call
qDebug("My debug text");
//Basic Output using QString
QString text = "My debug text";
qDebug(text.toAscii());
//Debug string with number
int times = 5;
qDebug("Loop was run "+QString::number(times).toAscii()+" times");

To output a number, the easiest way is to use QString’s static method ‘number’ to create a new QString and then output the QByteArray to qDebug.

C++ Crypto Libraries

As part of a project, I’ve been looking around for a simple to use C++ crypto  library that supports hashing and at least AES 128 encryption.  My requirements were pretty simple: I needed a library with a good API that I could use to encrypt the contents of a data file using a password.  I needed something that was standard and could be integrated in with Qt without a whole lot of effort, and I didn’t want something that would bloat my app with a lot of encryption mechanisms I don’t need.  I found three major libraries, however one was for MSVC and cost money, neither of which I have.  The other two, Crypto++ and Botan are free (as in beer) and I tried both.  Read on for my reviews.

Continue reading ‘C++ Crypto Libraries’