QTfrontend/newnetclient.cpp
changeset 2138 b246ad6484f5
parent 2108 a689375bbfee
child 2149 2eda77999bec
--- a/QTfrontend/newnetclient.cpp	Sun May 31 19:32:54 2009 +0000
+++ b/QTfrontend/newnetclient.cpp	Sun May 31 19:42:49 2009 +0000
@@ -452,9 +452,15 @@
 	}
 
 	if (lst[0] == "ASKPASSWORD") {
-		QString password = QInputDialog::getText(0, tr("Password"), tr("Enter your password:"), QLineEdit::Password);
+        int passLength = config->value("net/passwordlength", 0).toInt();
+        QString hash = config->value("net/passwordhash", "").toString();       
+		QString password = QInputDialog::getText(0, tr("Password"), tr("Enter your password:"), QLineEdit::Password, passLength==0?NULL:QString(passLength,'\0'));
 
-		QString hash = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5).toHex();
+        if (!passLength || password!=QString(passLength, '\0')) {
+            hash = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5).toHex();
+            config->setValue("net/passwordhash", hash);
+            config->setValue("net/passwordlength", password.size());
+        }
 
 		RawSendNet(QString("PASSWORD%1%2").arg(delimeter).arg(hash));
 		return;