Qt MD5算法加密

下面演示,将username 和 password加密的过程

#include 

   QString username = "admin";
QString password = "admin123";  
 QString fileName="./pwd.txt";
        QFile file(fileName);
        if(!file.open(QIODevice::ReadWrite | QIODevice::Text))
        {
           QMessageBox::warning(this,"warning","文件操作错误",QMessageBox::Yes);

        }
        QTextStream in(&file);
/**********加密开始***********/
        QString usernamemd5;
        QString pwdmd5;
       QByteArray bb;
        bb = QCryptographicHash::hash ( password.toAscii(), QCryptographicHash::Md5 );
        pwdmd5.append(bb.toHex());
        bb = QCryptographicHash::hash(username.toAscii(),QCryptographicHash::Md5);
        usernamemd5.append(bb.toHex());
/***********加密结束****************/
        //QMessageBox::warning(this,"warning",usernamemd5,QMessageBox::Yes);

        in<

你可能感兴趣的:(C++)