Add key2data and data2key function

pull/2/head
wh201906 5 years ago
parent c97c550439
commit 6080ac7d7c

@ -642,3 +642,47 @@ bool Mifare::data_loadKeyFile(const QString& filename)
return false; return false;
} }
} }
void Mifare::data_key2Data()
{
for(int i = 0; i < cardType.sectors; i++)
{
QString tmp = "";
dataList->replace(cardType.blks[i] + cardType.blk[i] - 1, "????????????FF078069????????????");
if(data_isKeyValid(keyAList->at(i)))
tmp += keyAList->at(i);
else
tmp += "????????????";
if(dataList->at(cardType.blks[i] + cardType.blk[i] - 1) == "")
tmp += "FF078069"; // default control bytes
else
tmp += dataList->at(cardType.blks[i] + cardType.blk[i] - 1).mid(12, 8);
if(data_isKeyValid(keyBList->at(i)))
tmp += keyBList->at(i);
else
tmp += "????????????";
dataList->replace(cardType.blks[i] + cardType.blk[i] - 1, tmp);
data_syncWithDataWidget();
}
}
void Mifare::data_data2Key()
{
for(int i = 0; i < cardType.sectors; i++)
{
if(dataList->at(cardType.blks[i] + cardType.blk[i] - 1) == "")
{
keyAList->replace(i, "????????????");
keyBList->replace(i, "????????????");
}
else
{
keyAList->replace(i, dataList->at(cardType.blks[i] + cardType.blk[i] - 1).left(12));
keyBList->replace(i, dataList->at(cardType.blks[i] + cardType.blk[i] - 1).right(12));
}
data_syncWithKeyWidget();
}
}

@ -94,11 +94,10 @@ public:
void wipeC(); void wipeC();
void setParameterC(); void setParameterC();
QStringList* keyAList;
QStringList* keyBList;
QStringList* dataList;
bool data_loadDataFile(const QString &filename); bool data_loadDataFile(const QString &filename);
bool data_loadKeyFile(const QString &filename); bool data_loadKeyFile(const QString &filename);
void data_key2Data();
void data_data2Key();
public slots: public slots:
signals: signals:
@ -107,7 +106,9 @@ private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
Util* util; Util* util;
QStringList* keyAList;
QStringList* keyBList;
QStringList* dataList;
QRegExp* dataPattern; QRegExp* dataPattern;
QRegExp* chkKeyPattern; QRegExp* chkKeyPattern;
QRegExp* nestedKeyPattern; QRegExp* nestedKeyPattern;

@ -182,6 +182,16 @@ void MainWindow::MF_onTypeChanged(int id, bool st)
typeBtnGroup->blockSignals(false); typeBtnGroup->blockSignals(false);
} }
void MainWindow::on_MF_data2KeyBotton_clicked()
{
mifare->data_data2Key();
}
void MainWindow::on_MF_key2DataBotton_clicked()
{
mifare->data_key2Data();
}
void MainWindow::on_MF_File_loadButton_clicked() void MainWindow::on_MF_File_loadButton_clicked()
{ {
QString title = ""; QString title = "";

@ -94,6 +94,10 @@ private slots:
void on_MF_File_saveButton_clicked(); void on_MF_File_saveButton_clicked();
void on_MF_data2KeyBotton_clicked();
void on_MF_key2DataBotton_clicked();
private: private:
Ui::MainWindow* ui; Ui::MainWindow* ui;
QButtonGroup* typeBtnGroup; QButtonGroup* typeBtnGroup;

Loading…
Cancel
Save