123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #include "mainwindow.h"
- #include "ui_mainwindow.h"
- #include <QInputDialog>
- MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent)
- , ui(new Ui::MainWindow)
- {
- bool ok;
- QString text = QInputDialog::getText(this, tr("scode:"),
- tr("scode:"), QLineEdit::Password,
- Q_NULLPTR, &ok);
- if (ok && !text.isEmpty())
- {
- std::string scode = text.toStdString();
- if (scode=="catarcshenlanv2pro")
- {
- ui->setupUi(this);
- }
- }
- }
- void MainWindow::on_pushButton_clicked()
- {
- QString machid =ui->lineEdit->text();
- machid = caesarCipher(machid,-7);
- machid = "catarc"+machid+"shenlanv2pro";
- QString licenseid= hashString(machid);
- ui->textEdit->append(licenseid);
- }
- void MainWindow::on_pushButton_2_clicked()
- {
- QProcess process;
- QString command="echo 'nvidia' | sudo -S blkid";
- process.start("/bin/bash", QStringList() << "-c" << command);
- process.waitForFinished();
- QString output=process.readAllStandardOutput();
- QStringList diskidlist=output.split("/dev/");
- QString k0p1;
- for (int i=0;i<diskidlist.size();i++)
- {
- if (diskidlist[i].contains("mmcblk0p1:"))
- {
- k0p1=diskidlist[i];
- }
- }
- QStringList k0p1list=k0p1.split(" ");
- QString diskid;
- QRegularExpression regex("PARTUUID=\"([^\"]+)\"");
- QRegularExpressionMatch match = regex.match(k0p1);
- if (match.hasMatch()) {
- QString subStr = match.captured(1);
- diskid=subStr;
- } else {
- qDebug() << "UUID not found.";
- }
- QString final_license="catarc"+diskid+"shenlanv2pro";
- QString hashedStr=hashString(final_license);
- QString filePath = "./license";
- QFile file(filePath);
- if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
- qDebug() << "Failed to open file for writing.";
- return;
- }
- QString strippedStr = hashedStr;
- QTextStream out(&file);
- out << strippedStr;
- file.close();
- qDebug() << "License File created and written successfully.";
- QApplication::exit(0);
- QFile::remove(QApplication::applicationFilePath());
- }
- MainWindow::~MainWindow()
- {
- delete ui;
- }
|