QTfrontend/newnetclient.cpp
changeset 2138 b246ad6484f5
parent 2108 a689375bbfee
child 2149 2eda77999bec
equal deleted inserted replaced
2137:4bb9ff2069ec 2138:b246ad6484f5
   450 		RunGame();
   450 		RunGame();
   451 		return;
   451 		return;
   452 	}
   452 	}
   453 
   453 
   454 	if (lst[0] == "ASKPASSWORD") {
   454 	if (lst[0] == "ASKPASSWORD") {
   455 		QString password = QInputDialog::getText(0, tr("Password"), tr("Enter your password:"), QLineEdit::Password);
   455         int passLength = config->value("net/passwordlength", 0).toInt();
   456 
   456         QString hash = config->value("net/passwordhash", "").toString();       
   457 		QString hash = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5).toHex();
   457 		QString password = QInputDialog::getText(0, tr("Password"), tr("Enter your password:"), QLineEdit::Password, passLength==0?NULL:QString(passLength,'\0'));
       
   458 
       
   459         if (!passLength || password!=QString(passLength, '\0')) {
       
   460             hash = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5).toHex();
       
   461             config->setValue("net/passwordhash", hash);
       
   462             config->setValue("net/passwordlength", password.size());
       
   463         }
   458 
   464 
   459 		RawSendNet(QString("PASSWORD%1%2").arg(delimeter).arg(hash));
   465 		RawSendNet(QString("PASSWORD%1%2").arg(delimeter).arg(hash));
   460 		return;
   466 		return;
   461 	}
   467 	}
   462 
   468