Qt学习-MD5加密处理的学习

目录

一:QCryptographicHash--生成密码散列

二:用户密码密文写入数据库

2.1 结果展示

2.2 代码实现


一:QCryptographicHash--生成密码散列

#include <QCryptographicHash>//生成密码散列

 

二:用户密码密文写入数据库

2.1 结果展示

2.2 代码实现

#include <QCryptographicHash>//生成密码散列
    QString GetMd5(const QString &value);//加密处理
//MD5加密设置
QString loginWidget::GetMd5(const QString &value)
{
    QString md5;
    QByteArray bb;//相当于是QChar的一个vector<>
    bb = QCryptographicHash::hash(value.toUtf8(), QCryptographicHash::Md5);
    md5.append(bb.toHex());
    return md5;
}
    int res=UserControl::getInstance()->doLogin(this->user_edit->text().trimmed(),GetMd5(this->password_edit->text().trimmed()));

其中的   trimmed()函数:去掉前后空格

猜你喜欢

转载自blog.csdn.net/m0_56051805/article/details/125194722