Qt Cryptographic Architecture
|
The code below shows the normal way to use the QCA::Cipher class.
#include <QtCrypto>
#include <cstdio>
#include <QCoreApplication>
#ifdef QT_STATICPLUGIN
#include "import_plugins.h"
#endif
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
printf("AES128-CBC not supported!\n");
else {
key, iv);
printf("Update failed\n");
}
printf("AES128 encryption of %s is [%s]\n",
printf("Final failed\n");
}
printf("Update failed\n");
}
printf("Decryption using AES128 of [0x%s] is %s\n",
plainText = cipher.
final();
printf("Final failed\n");
}
printf(
"Final decryption block using AES128 is %s\n", plainText.
data());
printf("One step decryption using AES128: %s\n",
}
return 0;
}
@ CBC
operate in Cipher Block Chaining mode
Definition: qca_basic.h:593
MemoryRegion update(const MemoryRegion &a) override
pass in a byte array of data, which will be encrypted or decrypted (according to the Direction that w...
General class for cipher (encryption / decryption) algorithms.
Definition: qca_basic.h:582
@ DefaultPadding
Default for cipher-mode.
Definition: qca_basic.h:610
QCA_EXPORT void init()
Initialise QCA.
MemoryRegion final() override
complete the block of data, padding as required, and returning the completed block
@ Encode
Operate in the "forward" direction; for example, encrypting.
Definition: qca_core.h:142
bool ok() const override
Test if an update() or final() call succeeded.
@ Decode
Operate in the "reverse" direction; for example, decrypting.
Definition: qca_core.h:143
Container for keys for symmetric encryption algorithms.
Definition: qca_core.h:1252
QByteArray toByteArray() const
Copy the contents of the secure array out to a standard QByteArray.
Container for initialisation vectors and nonces.
Definition: qca_core.h:1298
Secure array of bytes.
Definition: qca_tools.h:317
MemoryRegion process(const MemoryRegion &a)
Perform an "all in one" update, returning the result.
QCA_EXPORT QString arrayToHex(const QByteArray &array)
Convert a byte array to printable hexadecimal representation.
Convenience method for initialising and cleaning up QCA.
Definition: qca_core.h:660
QCA_EXPORT bool isSupported(const char *features, const QString &provider=QString())
Test if a capability (algorithm) is available.
void setup(Direction dir, const SymmetricKey &key, const InitializationVector &iv=InitializationVector())
Reset / reconfigure the Cipher.
SecureArray & append(const SecureArray &a)
Append a secure byte array to the end of this array.
char * data()
Pointer to the data in the secure array.