| ID | ... | Creation date | 10 April 2009 |
| Platform | S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition | Tested on devices | S60 Emulator |
| Category | Qt for S60 | Subcategory | UI |
| Keywords (APIs, classes, methods, functions): QCryptographicHash,QByteArray |
The QCryptographicHash class provides a way to generate cryptographic hashes from binary or text data.
For more information, see Wikipedia on http://en.wikipedia.org/wiki/Cryptographic_hash_function
QByteArray string = "Nokia"; QCryptographicHash hasher(QCryptographicHash::Sha1); hasher.addData(string);
QByteArray string1=hasher.result();
#include <QtGui/QApplication>
#include <QWidget>
#include <QHBoxLayout>
#include <QCryptographicHash>
#include <QString>
#include <QByteArray>
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *win=new QWidget();
QHBoxLayout *lay=new QHBoxLayout();
QLabel *lbl=new QLabel();
QLabel *lbl1=new QLabel("Encrypted Text:");
lbl1->setBuddy(lbl);
QByteArray string="Nokia";
QCryptographicHash *hash=new QCryptographicHash(QCryptographicHash::Md4);
hash->addData(string);
QByteArray string1=hash->result();
lbl->setText(string1); // TODO: use e.g. toHex or toBase64
lay->addWidget(lbl1);
lay->addWidget(lbl);
win->setLayout(lay);
win->setStyleSheet("* { background-color:rgb(199,147,88); padding: 7px ; color:rgb(255,255,255)}");
win->showMaximized();
return a.exec();
}
More About QCryptographicHash