diff --git a/README.md b/README.md index ca75260..e478b64 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,2 @@ -# python代码加密保护 - +# python-代码加密工具 把对应文件内的所有py文件进行代码加密,得到一个新的代码,以防被看到并修改源码并且不影响正常使用 - - -![截图_20230302144008](https://user-images.githubusercontent.com/111741364/222350905-a9211b6c-c98c-42f1-92a7-ae00ba3af5e6.png) - - -打开exe之后选择需要加密的代码文件夹,点击加密即可,加密后的代码文件会产生在工具文件的路径中 - -![截图_20230302144401](https://user-images.githubusercontent.com/111741364/222351424-53e5b426-61e5-4aef-9393-f0d4f43eb79b.png) - -![截图_20230302144411](https://user-images.githubusercontent.com/111741364/222351453-6b74d68d-a036-4220-8864-30ad6cf717db.png) - -文件夹内会有你的py代码以及一个pytransform文件夹,这个是关键 -运行代码的时候必需把这个文件放在同一路径下 - -例子: 源码文件 -![截图_20230302144710](https://user-images.githubusercontent.com/111741364/222352079-89940fa3-2306-4d42-93fa-7227e59c897d.png) - -选择对应文件夹内的py文件 -![截图_20230302144820](https://user-images.githubusercontent.com/111741364/222352327-c1b766e5-7426-49e4-8c61-b413b896d37d.png) - -点击加密 -![截图_20230302144851](https://user-images.githubusercontent.com/111741364/222352372-6ca1287e-eabd-41e2-b2bd-566c769dc139.png) - - - -点击dist之后即可看到代码 -![截图_20230302145002](https://user-images.githubusercontent.com/111741364/222352594-4b8b8b8a-71d7-4e3c-9a3b-e48c3de3d9f1.png) -![截图_20230302145022](https://user-images.githubusercontent.com/111741364/222352672-e04ad411-3631-49b4-b10a-a9084796aa57.png) - - - -可直接运行 -![截图_20230302145058](https://user-images.githubusercontent.com/111741364/222352787-73fee7d2-9025-4e95-a97f-44cc3714b0e8.png) - -也可以调用函数 -![截图_20230302145309](https://user-images.githubusercontent.com/111741364/222353203-8864ecca-de3d-4e0c-8e5a-98ab6c8f6c75.png) - -有什么想要增加的功能可以提一下 diff --git a/encrypt_logo.ico b/encrypt_logo.ico deleted file mode 100644 index 4a0c6f0..0000000 Binary files a/encrypt_logo.ico and /dev/null differ diff --git a/main.exe b/main.exe deleted file mode 100644 index 9e5efbf..0000000 Binary files a/main.exe and /dev/null differ diff --git a/main.py b/main.py deleted file mode 100644 index a0a1984..0000000 --- a/main.py +++ /dev/null @@ -1,80 +0,0 @@ -import sys,os,threading -from PySide6 import QtWidgets -from untitled import * -from PySide6.QtWidgets import QApplication, QMainWindow,QFileDialog,QMessageBox -from PySide6 import QtCore -import PySide6 -from subprocess import Popen, PIPE, STDOUT - -class Ui_MainWindows(QMainWindow): - def __init__(self): - super(Ui_MainWindows, self).__init__() - self.ui = Ui_MainWindow() - self.ui.setupUi(self) - self.anim = None - self.path = os.path.abspath(".") - self.effect_shadow_style(self.ui.frame) - self.bind_event() - self.setWindowTitle('Python代码加密工具') - self.setWindowIcon(QIcon('encrypt_logo.ico')) - - def bind_event(self): - self.ui.pushButton.clicked.connect(self.file_choices) - self.ui.pushButton_2.clicked.connect(self.encrypt_file) - self.ui.pushButton_3.clicked.connect(self.open_files) - - - def encrypt_file(self): - enc_path = self.ui.lineEdit.text() - process = Popen(["cmd"], shell=False, stdout=PIPE, stdin=PIPE, stderr=STDOUT) - commands = ( - f"pyarmor obfuscate {enc_path}\n" - ) - outs, errs = process.communicate(commands.encode('gbk')) - content = [z.strip() for z in outs.decode('gb18030').split("\n") if z] - # print(*content, sep="\n") - QMessageBox.information(self,'提示',content[-4]+'\n'+content[-3]) - - def file_choices(self): - folder_path = QFileDialog.getOpenFileName(self,'请选择要加密文件的所在文件夹') - self.ui.lineEdit.setText(folder_path[0]) - - def open_files(self): - def action(): - os.startfile(self.path) - t = threading.Thread(target=action) - t.setDaemon(True) - t.start() - - # 鼠标点击 - def mousePressEvent(self, event: PySide6.QtGui.QMouseEvent) -> None: - if event.button() == QtCore.Qt.LeftButton and self.isMaximized() == False: - self.m_flag = True - self.m_Position = event.globalPosition().toPoint() - self.pos() - event.accept() - self.setCursor(PySide6.QtGui.QCursor(QtCore.Qt.OpenHandCursor)) - - # 鼠标点拖之后移动 - def mouseMoveEvent(self, event: PySide6.QtGui.QMouseEvent) -> None: - if QtCore.Qt.LeftButton and self.m_flag: - self.move(event.globalPosition().toPoint() - self.m_Position) - event.accept() - - # 鼠标释放 - def mouseReleaseEvent(self, event: PySide6.QtGui.QMouseEvent) -> None: - self.m_flag = False - self.setCursor(PySide6.QtGui.QCursor(QtCore.Qt.ArrowCursor)) - - def effect_shadow_style(self, widget): - effect_shadow = QtWidgets.QGraphicsDropShadowEffect(self) - effect_shadow.setOffset(0, 8) # 偏移 - effect_shadow.setBlurRadius(48) # 阴影半径 - effect_shadow.setColor(QColor(162, 129, 247)) # 阴影颜色 - widget.setGraphicsEffect(effect_shadow) - - -if __name__ == '__main__': - app = QApplication(sys.argv) - window = Ui_MainWindows() - window.show() - sys.exit(app.exec()) \ No newline at end of file diff --git a/pyarmor.exe b/pyarmor.exe deleted file mode 100644 index d2c7eee..0000000 Binary files a/pyarmor.exe and /dev/null differ diff --git a/untitled.py b/untitled.py deleted file mode 100644 index 2428909..0000000 --- a/untitled.py +++ /dev/null @@ -1,141 +0,0 @@ -# -*- coding: utf-8 -*- - -################################################################################ -## Form generated from reading UI file 'untitled.ui' -## -## Created by: Qt User Interface Compiler version 6.4.0 -## -## WARNING! All changes made in this file will be lost when recompiling UI file! -################################################################################ - -from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale, - QMetaObject, QObject, QPoint, QRect, - QSize, QTime, QUrl, Qt) -from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor, - QFont, QFontDatabase, QGradient, QIcon, - QImage, QKeySequence, QLinearGradient, QPainter, - QPalette, QPixmap, QRadialGradient, QTransform) -from PySide6.QtWidgets import (QApplication, QFrame, QHBoxLayout, QLabel, - QLineEdit, QMainWindow, QPushButton, QSizePolicy, - QSpacerItem, QVBoxLayout, QWidget) - -class Ui_MainWindow(object): - def setupUi(self, MainWindow): - if not MainWindow.objectName(): - MainWindow.setObjectName(u"MainWindow") - MainWindow.resize(302, 177) - self.centralwidget = QWidget(MainWindow) - self.centralwidget.setObjectName(u"centralwidget") - self.verticalLayout = QVBoxLayout(self.centralwidget) - self.verticalLayout.setObjectName(u"verticalLayout") - self.frame = QFrame(self.centralwidget) - self.frame.setObjectName(u"frame") - self.frame.setFrameShape(QFrame.StyledPanel) - self.frame.setFrameShadow(QFrame.Raised) - self.verticalLayout_2 = QVBoxLayout(self.frame) - self.verticalLayout_2.setObjectName(u"verticalLayout_2") - self.label = QLabel(self.frame) - self.label.setObjectName(u"label") - font = QFont() - font.setPointSize(12) - self.label.setFont(font) - self.label.setTextFormat(Qt.RichText) - self.label.setAlignment(Qt.AlignCenter) - - self.verticalLayout_2.addWidget(self.label) - - self.widget = QWidget(self.frame) - self.widget.setObjectName(u"widget") - self.horizontalLayout = QHBoxLayout(self.widget) - self.horizontalLayout.setObjectName(u"horizontalLayout") - self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) - - self.horizontalLayout.addItem(self.horizontalSpacer) - - self.lineEdit = QLineEdit(self.widget) - self.lineEdit.setObjectName(u"lineEdit") - self.lineEdit.setMinimumSize(QSize(170, 20)) - self.lineEdit.setMaximumSize(QSize(1000000, 20)) - - self.horizontalLayout.addWidget(self.lineEdit) - - self.horizontalSpacer_2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) - - self.horizontalLayout.addItem(self.horizontalSpacer_2) - - self.pushButton = QPushButton(self.widget) - self.pushButton.setObjectName(u"pushButton") - self.pushButton.setEnabled(True) - sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.pushButton.sizePolicy().hasHeightForWidth()) - self.pushButton.setSizePolicy(sizePolicy) - self.pushButton.setMaximumSize(QSize(30, 25)) - - self.horizontalLayout.addWidget(self.pushButton) - - self.horizontalSpacer_3 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) - - self.horizontalLayout.addItem(self.horizontalSpacer_3) - - - self.verticalLayout_2.addWidget(self.widget) - - self.widget_2 = QWidget(self.frame) - self.widget_2.setObjectName(u"widget_2") - self.horizontalLayout_2 = QHBoxLayout(self.widget_2) - self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") - self.horizontalSpacer_4 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) - - self.horizontalLayout_2.addItem(self.horizontalSpacer_4) - - self.pushButton_2 = QPushButton(self.widget_2) - self.pushButton_2.setObjectName(u"pushButton_2") - self.pushButton_2.setMinimumSize(QSize(50, 0)) - self.pushButton_2.setMaximumSize(QSize(0, 16777215)) - - self.horizontalLayout_2.addWidget(self.pushButton_2) - - self.horizontalSpacer_6 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) - - self.horizontalLayout_2.addItem(self.horizontalSpacer_6) - - self.pushButton_3 = QPushButton(self.widget_2) - self.pushButton_3.setObjectName(u"pushButton_3") - self.pushButton_3.setMaximumSize(QSize(60, 16777215)) - - self.horizontalLayout_2.addWidget(self.pushButton_3) - - self.horizontalSpacer_5 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) - - self.horizontalLayout_2.addItem(self.horizontalSpacer_5) - - - self.verticalLayout_2.addWidget(self.widget_2) - - self.label_2 = QLabel(self.frame) - self.label_2.setObjectName(u"label_2") - self.label_2.setMaximumSize(QSize(260, 20)) - - self.verticalLayout_2.addWidget(self.label_2) - - - self.verticalLayout.addWidget(self.frame) - - MainWindow.setCentralWidget(self.centralwidget) - - self.retranslateUi(MainWindow) - - QMetaObject.connectSlotsByName(MainWindow) - # setupUi - - def retranslateUi(self, MainWindow): - MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None)) - self.label.setText(QCoreApplication.translate("MainWindow", u"Python\u6587\u4ef6\u52a0\u5bc6\u5de5\u5177", None)) - self.pushButton.setText(QCoreApplication.translate("MainWindow", u"...", None)) - self.pushButton_2.setText(QCoreApplication.translate("MainWindow", u"\u52a0\u5bc6", None)) - self.pushButton_3.setText(QCoreApplication.translate("MainWindow", u"\u6253\u5f00\u76ee\u5f55", None)) - self.label_2.setText(QCoreApplication.translate("MainWindow", u"tips:\u4e0d\u8981\u7528\u6709\u4e2d\u6587\u8def\u5f84\u7684\u6587\u4ef6 By:\u5377\u997c\u5237", None)) - # retranslateUi - diff --git a/untitled.ui b/untitled.ui deleted file mode 100644 index e1cf0aa..0000000 --- a/untitled.ui +++ /dev/null @@ -1,226 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 302 - 177 - - - - MainWindow - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - 12 - - - - Python文件加密工具 - - - Qt::RichText - - - Qt::AlignCenter - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 170 - 20 - - - - - 1000000 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - true - - - - 0 - 0 - - - - - 30 - 25 - - - - ... - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 50 - 0 - - - - - 0 - 16777215 - - - - 加密 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 60 - 16777215 - - - - 打开目录 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - 260 - 20 - - - - tips:不要用有中文路径的文件 By:卷饼刷 - - - - - - - - - - - -