How to calculate hash for a text using QCryptographicHash in Qt
m (Qt Software) |
mind_freak
(Talk | contribs) |
||
| Line 7: | Line 7: | ||
|devices= S60 Emulator | |devices= S60 Emulator | ||
|category=Qt for S60 | |category=Qt for S60 | ||
| − | |subcategory= | + | |subcategory=UI |
|creationdate=10 April 2009 | |creationdate=10 April 2009 | ||
|keywords=QCryptographicHash,QByteArray | |keywords=QCryptographicHash,QByteArray | ||
| Line 18: | Line 18: | ||
==Preconditions== | ==Preconditions== | ||
| − | |||
* [http://pepper.troll.no/s60prereleases/ Download the latest Qt for S60 distribution from Qt]. | * [http://pepper.troll.no/s60prereleases/ Download the latest Qt for S60 distribution from Qt]. | ||
* Install Qt for S60:[[Installing Qt on S60]] | * Install Qt for S60:[[Installing Qt on S60]] | ||
* Check this link for installation guide: [http://pepper.troll.no/s60prereleases/doc/install-s60.html How to install the package]. | * Check this link for installation guide: [http://pepper.troll.no/s60prereleases/doc/install-s60.html How to install the package]. | ||
| − | * Go through this article: [[Getting started with Qt for S60] | + | * Go through this article: [[Getting started with Qt for S60] |
| − | + | ||
== Some Related Function == | == Some Related Function == | ||
| Line 65: | Line 63: | ||
win->setLayout(lay); | win->setLayout(lay); | ||
win->setStyleSheet("* { background-color:rgb(199,147,88); padding: 7px ; color:rgb(255,255,255)}"); | win->setStyleSheet("* { background-color:rgb(199,147,88); padding: 7px ; color:rgb(255,255,255)}"); | ||
| − | win-> | + | win->showMaximized(); |
return a.exec(); | return a.exec(); | ||
} | } | ||
Revision as of 08:57, 12 August 2009
Article Metadata
Tested with
Devices(s): S60 Emulator
Compatibility
Platform(s): S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition
Article
Keywords: QCryptographicHash,QByteArray
Created: (10 Apr 2009)
Last edited: mind_freak
(12 Aug 2009)
Introduction
The QCryptographicHash class provides a way to generate cryptographic hashes.
QCryptographicHash can be used to generate cryptographic hashes of binary or text data.
Preconditions
- Download the latest Qt for S60 distribution from Qt.
- Install Qt for S60:Installing Qt on S60
- Check this link for installation guide: How to install the package.
- Go through this article: [[Getting started with Qt for S60]
Some Related Function
- Adds the data to the cryptographic hash.
QByteArray string="Nokia"; hash->addData(string);
- Returns the final hash value.
QByteArray string1=hash->result();
Source Code
Main.cpp
#include <QtGui/QApplication>
#include "textcodec.h"
#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);
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();
}
ScreenShot
More About QCryptographicHash

