包含的头文件
#include "QCryptographicHash"
具体代码实现
/*! 通过hash中的sha1加密方式加密 */ QCryptographicHash Hash(QCryptographicHash::Sha1); QString word = ui->edit_word->text(); Hash.addData(word.toLatin1().data()); ui->edit_hash->setText(Hash.result().toHex().toUpper()); /*! 通过hash中的md5加密方式加密 */ QCryptographicHash MD5(QCryptographicHash::Md5); MD5.addData(word.toLatin1().data()); ui->edit_md5->setText(MD5.result().toHex().toUpper()); /*! 通过hash中的sha224加密方式加密 */ QCryptographicHash SHA224(QCryptographicHash::Sha224); SHA224.addData(word.toLatin1().data()); ui->edit_sha224->setText(SHA224.result().toHex().toUpper()); /*! 通过hash中的sha256加密方式加密 */ QCryptographicHash SHA256(QCryptographicHash::Sha256); SHA256.addData(word.toLatin1().data()); ui->edit_sha256->setText(SHA256.result().toHex().toUpper()); /*! 通过hash中的sha512加密方式加密 */ QCryptographicHash SHA512(QCryptographicHash::Sha512); SHA512.addData(word.toLatin1().data()); ui->edit_sha512->setText(SHA512.result().toHex().toUpper());