Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

如何使用QCryptographicHash加密文本

From Wiki
Jump to: navigation, search
Article Metadata

兼容于
平台:
Symbian

文章
dougcn 在 18 Apr 2009 创建
最后由 hamishwillee 在 11 Oct 2012 编辑
  • 平 台:S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition
  • 设 备:S60 Emulator
  • 类 别:Qt for Symbian, Garden release
  • 关键字:QCryptographicHash,QByteArray

Contents

简介

QCryptographicHash类提供生成加密哈希值的方法。

QCryptographicHash可用来生成二进制或文件数据的加密哈希值。目前支持三种算法:Md4, Md5, Sha1。

前提条件

一些相关函数

  • 添加数据到加密哈希值
QByteArray string="Nokia";
hash->addData(string);
  • 返回最终的哈希值
QByteArray string1=hash->result();

源代码

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->show();
return a.exec();
}

屏幕截图

更多参考:QCryptographicHash

Crypto.JPG

This page was last modified on 11 October 2012, at 01:19.
200 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.

×