×
Namespaces

Variants
Actions
(Difference between revisions)

How to calculate hash for a text using QCryptographicHash in Qt

From Nokia Developer Wiki
Jump to: navigation, search
mind_freak (Talk | contribs)
m
croozeus (Talk | contribs)
m (Qt for S60 to Qt for Symbian)
Line 1: Line 1:
[[Category:Qt]][[Category:Qt for S60]][[Category:Code Examples]]
+
[[Category:Qt]][[Category:Qt for Symbian]][[Category:Code Examples]]
 
__NOTOC__
 
__NOTOC__
 
__NOEDITSECTION__
 
__NOEDITSECTION__

Revision as of 09:31, 3 September 2009


Article Metadata
Tested with
Devices(s): S60 Emulator
Compatibility
Platform(s): S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition
Symbian
Article
Keywords: QCryptographicHash,QByteArray
Created: (10 Apr 2009)
Last edited: croozeus (03 Sep 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.

This cryptography is used when you want to send any data in secure way to the other.The encrypted text is called chiper text.

Preconditions

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

Crypto.JPG

283 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×