mainwindow.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. #include <QInputDialog>
  4. MainWindow::MainWindow(QWidget *parent)
  5. : QMainWindow(parent)
  6. , ui(new Ui::MainWindow)
  7. {
  8. bool ok;
  9. QString text = QInputDialog::getText(this, tr("scode:"),
  10. tr("scode:"), QLineEdit::Password,
  11. Q_NULLPTR, &ok);
  12. if (ok && !text.isEmpty())
  13. {
  14. std::string scode = text.toStdString();
  15. if (scode=="catarcshenlanv2pro")
  16. {
  17. ui->setupUi(this);
  18. }
  19. }
  20. }
  21. void MainWindow::on_pushButton_clicked()
  22. {
  23. QString machid =ui->lineEdit->text();
  24. machid = caesarCipher(machid,-7);
  25. machid = "catarc"+machid+"shenlanv2pro";
  26. QString licenseid= hashString(machid);
  27. ui->textEdit->append(licenseid);
  28. }
  29. void MainWindow::on_pushButton_2_clicked()
  30. {
  31. QProcess process;
  32. QString command="echo 'nvidia' | sudo -S blkid";
  33. process.start("/bin/bash", QStringList() << "-c" << command);
  34. process.waitForFinished();
  35. QString output=process.readAllStandardOutput();
  36. QStringList diskidlist=output.split("/dev/");
  37. QString k0p1;
  38. for (int i=0;i<diskidlist.size();i++)
  39. {
  40. if (diskidlist[i].contains("mmcblk0p1:"))
  41. {
  42. k0p1=diskidlist[i];
  43. }
  44. }
  45. QStringList k0p1list=k0p1.split(" ");
  46. QString diskid;
  47. QRegularExpression regex("PARTUUID=\"([^\"]+)\"");
  48. QRegularExpressionMatch match = regex.match(k0p1);
  49. if (match.hasMatch()) {
  50. QString subStr = match.captured(1);
  51. diskid=subStr;
  52. } else {
  53. qDebug() << "UUID not found.";
  54. }
  55. QString final_license="catarc"+diskid+"shenlanv2pro";
  56. QString hashedStr=hashString(final_license);
  57. QString filePath = "./license";
  58. QFile file(filePath);
  59. if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
  60. qDebug() << "Failed to open file for writing.";
  61. return;
  62. }
  63. QString strippedStr = hashedStr;
  64. QTextStream out(&file);
  65. out << strippedStr;
  66. file.close();
  67. qDebug() << "License File created and written successfully.";
  68. QApplication::exit(0);
  69. QFile::remove(QApplication::applicationFilePath());
  70. }
  71. MainWindow::~MainWindow()
  72. {
  73. delete ui;
  74. }