qtMd5 加密算法

       QString username = "admin";  

  1. String password = "admin123";    
  2. QString fileName="./pwd.txt";  
  3.        QFile file(fileName);  
  4. if(!file.open(QIODevice::ReadWrite | QIODevice::Text))  
  5.        {  
  6.           QMessageBox::warning(this,"warning","文件操作错误",QMessageBox::Yes);  
  7.        }  
  8.        QTextStream in(&file);  
  9. **********加密开始***********/  
  10.        QString usernamemd5;  
  11.        QString pwdmd5;  
  12.       QByteArray bb;  
  13.        bb = QCryptographicHash::hash ( password.toAscii(), QCryptographicHash::Md5 );  
  14.        pwdmd5.append(bb.toHex());  
  15.        bb = QCryptographicHash::hash(username.toAscii(),QCryptographicHash::Md5);  
  16.        usernamemd5.append(bb.toHex());  
  17. ***********加密结束****************/  
  18. //QMessageBox::warning(this,"warning",usernamemd5,QMessageBox::Yes);  
  19.        in<<usernamemd5+" ";  
  20.        in<<pwdmd5+" ";  
  21.        file.close();//到文件里看结果吧~当然用上面的消息框也可以哦  
只有不断学习,才可进步。
原文地址:https://www.cnblogs.com/onlyforliu/p/5685623.html