SIFE
29th December 2011, 23:10
I am trying to compare QString against char*, but I fail to do that:
void Register::checkKey()
{
QMessageBox sd;
QFile kFile("license.key");
if (!kFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
sd.setText("The registration key doesn't exist.\n");
sd.exec();
exit(0);
}
QTextStream key(&kFile);
QString test = key.readLine();
kFile.close();
QString hash = GetMacAddress();
char ser[22];
hdidnt(ser);
QByteArray Id(ser);
hash += QString::fromUtf8(Id);
char *crypt = hash.toUtf8().data();
encrypt(crypt, "key");
MD5 md;
if (test != QString::fromUtf8(md.digestString(md.digestString( md.digestString(crypt)))))
{
QMessageBox sdf;
sdf.setText(QString::fromUtf8(md.digestString(md.d igestString(md.digestString(crypt)))) + "\n" \
+ test + "\n" \
+ QString::number(sizeof(test.toUtf8())) + "\n" \
);
sdf.exec();
sd.setText("This product must have a valid key.\n");
sd.exec();
KeyDialog kDialog;
kDialog.setKey(QString::fromUtf8(md.digestString(c rypt)));
kDialog.exec();
exit(0);
}
}
I tryied also to convert QString to char* then make the comparison but I fail too. Both QString test and md.digestString(md.digestString(md.digestString(cr ypt))) return some value but they unenable to compare.
void Register::checkKey()
{
QMessageBox sd;
QFile kFile("license.key");
if (!kFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
sd.setText("The registration key doesn't exist.\n");
sd.exec();
exit(0);
}
QTextStream key(&kFile);
QString test = key.readLine();
kFile.close();
QString hash = GetMacAddress();
char ser[22];
hdidnt(ser);
QByteArray Id(ser);
hash += QString::fromUtf8(Id);
char *crypt = hash.toUtf8().data();
encrypt(crypt, "key");
MD5 md;
if (test != QString::fromUtf8(md.digestString(md.digestString( md.digestString(crypt)))))
{
QMessageBox sdf;
sdf.setText(QString::fromUtf8(md.digestString(md.d igestString(md.digestString(crypt)))) + "\n" \
+ test + "\n" \
+ QString::number(sizeof(test.toUtf8())) + "\n" \
);
sdf.exec();
sd.setText("This product must have a valid key.\n");
sd.exec();
KeyDialog kDialog;
kDialog.setKey(QString::fromUtf8(md.digestString(c rypt)));
kDialog.exec();
exit(0);
}
}
I tryied also to convert QString to char* then make the comparison but I fail too. Both QString test and md.digestString(md.digestString(md.digestString(cr ypt))) return some value but they unenable to compare.