Pyinstaller 암호 화 패키지 응용 예시 코드

pyinstaller 는 python 의 py 파일 을 아주 간단하게 포장 하 는 라 이브 러 리 입 니 다.사용 하면 명령 몇 개 면 충분 한데,
공식 문서:pyinstaller
코드 혼동
코드 혼동https://pyob.oxyry.com/을 사용 하여 코드 혼동(사용 가능 한 오프라인 혼동 라 이브 러 리 를 찾 을 수 없습니다)
image.png
실제 api 캡 처 후

def obfuscation(py_file, save_path):
 print("    :", py_file)
 with open(py_file, "r", encoding="utf-8") as f:
  py_content = f.read()

 print("     ...")
 url = "https://pyob.oxyry.com/obfuscate"
 headers = {
  "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36",
  "Referer": "http://pyob.oxyry.com/",
  "content-type": "application/json",
  "cookie": "_ga=GA1.2.1306886713.1588752647; _gid=GA1.2.46944674.1588899118"
 }
 data = json.dumps({
  "append_source": "false",
  "preserve": "",
  "remove_docstrings": "true",
  "rename_default_parameters": "false",
  "rename_nondefault_parameters": "true",
  "source": py_content
 })
 result = json.loads(requests.post(url, data=data, headers=headers).text)["dest"]
 result = "# cython: language_level=3
" + result print(" ...") with open(save_path, "w", encoding="utf-8") as f: f.write(result) print(" {}
".format(save_path)) if __name__ == '__main__': obfuscation("my.py", "../ /my.py") obfuscation("approach.py", "../ /approach.py")
컴 파일 pyd
build_pyd.py

from distutils.core import setup
from Cython.Build import cythonize

setup(
 name='any words.....',
 ext_modules=cythonize(["my.py","approach.py" ])
)
실행 패키지

import json
import os
#    pyd  
import uuid
import requests
def clearPyd():
 for file in os.listdir():
  if ".pyd" in file:
   print("  .pyd:", file)
   os.remove(file)
 print("***********************************************************************")
#   pyd  
def buildPyd():
 os.system("python build_pyd.py build_ext --inplace")
#    pyd  
def renamePyd():
 print("***********************************************************************")
 for file in os.listdir():
  if ".pyd" in file:
   print("    pyd:", file)
   os.rename(file, file[:file.find(".")] + ".pyd")
 for file in os.listdir():
  if ".c" in file:
   print("  .c  :", file)
   os.remove(file)
 print("***********************************************************************")
#     
def pyinstaller(key, ico):
 os.system("pyinstaller -F --key {} -i {} main.py".format(key, ico))
#   bulid spec  
def clearBuildAndSpec():
 import shutil
 shutil.rmtree('build')
 print("  bulid   ")
 os.remove("main.spec")
 print("  spec  ")
if __name__ == '__main__':
 clearPyd() #    pyd  
 buildPyd() #   pyd  
 renamePyd() #    pyd  
 pyinstaller(uuid.uuid4()[0:16], "1.ico") #     
 clearPyd() #   pyd  
 clearBuildAndSpec() #   bulid spec  
총결산
Pyinstaller 암호 화 패키지 애플 리 케 이 션 에 관 한 이 글 은 여기까지 소개 되 었 습 니 다.더 많은 Pyinstaller 암호 화 패키지 내용 은 예전 의 글 을 검색 하거나 아래 의 관련 글 을 계속 찾 아 보 세 요.앞으로 많은 응원 부탁드립니다!

좋은 웹페이지 즐겨찾기