Browse Source

Get license tool

dongjunhong 2 months ago
parent
commit
d7fe2d34b5

+ 73 - 0
src/tool/tool_getLicense/.gitignore

@@ -0,0 +1,73 @@
+# This file is used to ignore files which are generated
+# ----------------------------------------------------------------------------
+
+*~
+*.autosave
+*.a
+*.core
+*.moc
+*.o
+*.obj
+*.orig
+*.rej
+*.so
+*.so.*
+*_pch.h.cpp
+*_resource.rc
+*.qm
+.#*
+*.*#
+core
+!core/
+tags
+.DS_Store
+.directory
+*.debug
+Makefile*
+*.prl
+*.app
+moc_*.cpp
+ui_*.h
+qrc_*.cpp
+Thumbs.db
+*.res
+*.rc
+/.qmake.cache
+/.qmake.stash
+
+# qtcreator generated files
+*.pro.user*
+
+# xemacs temporary files
+*.flc
+
+# Vim temporary files
+.*.swp
+
+# Visual Studio generated files
+*.ib_pdb_index
+*.idb
+*.ilk
+*.pdb
+*.sln
+*.suo
+*.vcproj
+*vcproj.*.*.user
+*.ncb
+*.sdf
+*.opensdf
+*.vcxproj
+*vcxproj.*
+
+# MinGW generated files
+*.Debug
+*.Release
+
+# Python byte code
+*.pyc
+
+# Binaries
+# --------
+*.dll
+*.exe
+

+ 7 - 22
src/tool/tool_getLicense/main.cpp

@@ -1,26 +1,11 @@
-#include <QCoreApplication>
-#include "QDebug"
+#include "mainwindow.h"
+
+#include <QApplication>
+
 int main(int argc, char *argv[])
 {
-    QCoreApplication a(argc, argv);
-        QString str="640d0df56d6g876cc1d0c49c99h4156c";
-        QString decryptedText;
-        for (int i = 0; i < str.length(); ++i) {
-                QChar currentChar = str.at(i);
-                if (currentChar.isLetter()) {
-                    QChar decryptedChar = (currentChar.toLatin1() - 'a' - 2 + 26) % 26 + 'a'; // 反解密操作
-                    if (currentChar.isUpper()) {
-                        decryptedChar = (currentChar.toLatin1() - 'A' - 2 + 26) % 26 + 'A'; // 如果是大写字母
-                    }
-                    decryptedText.append(decryptedChar);
-                } else if (currentChar.isDigit()) {
-                    QChar decryptedChar = (currentChar.toLatin1() - '0' - 4 + 10) % 10 + '0'; // 反解密操作
-                    decryptedText.append(decryptedChar);
-                } else {
-                    decryptedText.append(currentChar); // 如果不是字母或数字,则保持不变
-                }
-            }
-        qDebug()<< decryptedText;
-
+    QApplication a(argc, argv);
+    MainWindow w;
+    w.show();
     return a.exec();
 }

+ 22 - 0
src/tool/tool_getLicense/mainwindow.cpp

@@ -0,0 +1,22 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent)
+    : QMainWindow(parent)
+    , ui(new Ui::MainWindow)
+{
+    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);
+}
+MainWindow::~MainWindow()
+{
+    delete ui;
+}
+

+ 48 - 0
src/tool/tool_getLicense/mainwindow.h

@@ -0,0 +1,48 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+#include <QCryptographicHash>
+#include <QMainWindow>
+
+QT_BEGIN_NAMESPACE
+namespace Ui { class MainWindow; }
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    MainWindow(QWidget *parent = nullptr);
+    ~MainWindow();
+private slots:
+
+    void on_pushButton_clicked();
+private:
+    Ui::MainWindow *ui;
+    QString hashString(const QString &str) {
+        QString strippedStr = str;
+        strippedStr.remove(QChar('-'));
+        QByteArray hashData = QCryptographicHash::hash(strippedStr.toUtf8(), QCryptographicHash::Sha256);
+        QString hashedStr = QString::fromLatin1(hashData.toHex());
+        return hashedStr;
+    }
+    QString caesarCipher(const QString &text, int shift) {
+        QString result;
+        const int alphabetSize = 26;
+        const int digitSize = 10;
+
+        for (const QChar &ch : text) {
+            if (ch.isLetter()) {
+                QChar base = ch.isLower() ? 'a' : 'A';
+                result.append(QChar((ch.toLatin1() - base.toLatin1() + shift + alphabetSize) % alphabetSize + base.toLatin1()));
+            } else if (ch.isDigit()) {
+                result.append(QChar((ch.toLatin1() - '0' + shift + digitSize) % digitSize + '0'));
+            } else {
+                result.append(ch);
+            }
+        }
+
+        return result;
+    }
+};
+#endif // MAINWINDOW_H

+ 78 - 0
src/tool/tool_getLicense/mainwindow.ui

@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>433</width>
+    <height>175</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <widget class="QLabel" name="label">
+    <property name="geometry">
+     <rect>
+      <x>20</x>
+      <y>21</y>
+      <width>101</width>
+      <height>20</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>请输入机器码</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushButton">
+    <property name="geometry">
+     <rect>
+      <x>340</x>
+      <y>20</y>
+      <width>60</width>
+      <height>25</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>生成</string>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit">
+    <property name="geometry">
+     <rect>
+      <x>120</x>
+      <y>20</y>
+      <width>211</width>
+      <height>25</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QTextEdit" name="textEdit">
+    <property name="geometry">
+     <rect>
+      <x>30</x>
+      <y>50</y>
+      <width>371</width>
+      <height>70</height>
+     </rect>
+    </property>
+   </widget>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>433</width>
+     <height>22</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 12 - 4
src/tool/tool_getLicense/tool_getLicense.pro

@@ -1,7 +1,8 @@
-QT -= gui
+QT       += core gui
 
-CONFIG += c++11 console
-CONFIG -= app_bundle
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++11
 
 # The following define makes your compiler emit warnings if you use
 # any Qt feature that has been marked deprecated (the exact warnings
@@ -15,7 +16,14 @@ DEFINES += QT_DEPRECATED_WARNINGS
 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
 
 SOURCES += \
-        main.cpp
+    main.cpp \
+    mainwindow.cpp
+
+HEADERS += \
+    mainwindow.h
+
+FORMS += \
+    mainwindow.ui
 
 # Default rules for deployment.
 qnx: target.path = /tmp/$${TARGET}/bin