Skip to content

Commit

Permalink
feat: 🎸 replace pyminifier using python-minifier
Browse files Browse the repository at this point in the history
Closes: #28
  • Loading branch information
ZhaoQi99 committed Dec 14, 2023
1 parent 8a06bb0 commit 4d6711d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
24 changes: 7 additions & 17 deletions pyencrypt/encrypt.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os
import re
import subprocess
from pathlib import Path

import python_minifier

from pyencrypt.aes import aes_encrypt
from pyencrypt.generate import generate_rsa_number
from pyencrypt.ntt import ntt
Expand Down Expand Up @@ -73,28 +74,17 @@ def generate_so_file(cipher_key: str, d: int, n: int, base_dir: Path = None, lic
loader_file_path.touch(exist_ok=True)

decrypt_source = '\n'.join(decrypt_source_ls)
loader_file_path.write_text(f"{decrypt_source}\n{loader_source}")

# Origin file
loader_origin_file_path = temp_dir / 'loader_origin.py'
loader_origin_file_path.touch(exist_ok=True)
loader_origin_file_path.write_text(f"{decrypt_source}\n{loader_source}")

args = [
'pyminifier',
'--obfuscate-classes',
'--obfuscate-import-methods',
'--replacement-length',
'20',
'-o',
loader_file_path.as_posix(),
loader_file_path.as_posix(),
]
ret = subprocess.run(args, shell=False, encoding='utf-8')
if ret.returncode == 0:
pass

from setuptools import setup
loader_file_path.write_text(
python_minifier.minify(loader_origin_file_path.read_text())
)

from setuptools import setup # isort:skip
from Cython.Build import cythonize
from Cython.Distutils import build_ext
setup(
Expand Down
2 changes: 1 addition & 1 deletion requirement.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
click==8.0.3
Cython==0.29.24
pycryptodome==3.14.1
pyminifier==2.1
python-minifier==2.9.0
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ keywords = python-encrypt, import-hook
install_requires =
Cython >= 0.29.24
pycryptodome >= 3.14.1
pyminifier >= 2.1
python-minifier >= 2.6.0
click
python_requires = >=3.6
packages = find:
Expand Down

0 comments on commit 4d6711d

Please sign in to comment.