|
|
|
@ -0,0 +1,71 @@
|
|
|
|
|
from PyQt5.QtWidgets import QApplication, QMainWindow
|
|
|
|
|
from PyQt5.QtCore import Qt
|
|
|
|
|
import Decipher
|
|
|
|
|
import sys
|
|
|
|
|
import UI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_valid_md4_hash(text):
|
|
|
|
|
"""
|
|
|
|
|
检查输入是否为有效的 MD4 哈希值(32位十六进制字符串)
|
|
|
|
|
"""
|
|
|
|
|
# 检查字符是否为十六进制字符(0-9, a-f, A-F)
|
|
|
|
|
for char in text:
|
|
|
|
|
if char not in "0123456789abcdefABCDEF":
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PagesWindow(QMainWindow, UI.Ui_MainWindow):
|
|
|
|
|
def __init__(self):
|
|
|
|
|
# 调用父类的构造函数
|
|
|
|
|
super(PagesWindow, self).__init__()
|
|
|
|
|
# 初始化UI
|
|
|
|
|
self.setupUi(self)
|
|
|
|
|
# 设置窗口无边框
|
|
|
|
|
self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
|
|
|
|
|
# 绑定按钮点击事件
|
|
|
|
|
self.pushButton.clicked.connect(self.handle_button_click)
|
|
|
|
|
|
|
|
|
|
def handle_button_click(self):
|
|
|
|
|
"""
|
|
|
|
|
处理按钮点击事件
|
|
|
|
|
"""
|
|
|
|
|
# 清空输出框
|
|
|
|
|
self.textEdit_2.clear()
|
|
|
|
|
# 获取输入框的文本
|
|
|
|
|
text = self.textEdit.toPlainText().strip()
|
|
|
|
|
|
|
|
|
|
# 输入验证
|
|
|
|
|
if not text:
|
|
|
|
|
self.textEdit_2.append('请输入密文')
|
|
|
|
|
return
|
|
|
|
|
elif len(text) != 32:
|
|
|
|
|
self.textEdit_2.append('请输入有效密文')
|
|
|
|
|
return
|
|
|
|
|
elif not is_valid_md4_hash(text):
|
|
|
|
|
self.textEdit_2.append('请输入有效密文')
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# 调用 Decipher.Decipher 函数进行破解
|
|
|
|
|
result = Decipher.Decipher(text, 6)
|
|
|
|
|
|
|
|
|
|
# 显示破解结果
|
|
|
|
|
if result is None:
|
|
|
|
|
self.textEdit_2.append('破译失败')
|
|
|
|
|
else:
|
|
|
|
|
self.textEdit_2.append(result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
# 创建应用程序对象
|
|
|
|
|
app = QApplication(sys.argv)
|
|
|
|
|
|
|
|
|
|
# 创建主窗口对象
|
|
|
|
|
main_window = PagesWindow()
|
|
|
|
|
|
|
|
|
|
# 显示主窗口
|
|
|
|
|
main_window.show()
|
|
|
|
|
|
|
|
|
|
# 进入应用程序主循环,等待事件触发
|
|
|
|
|
sys.exit(app.exec_())
|