日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Python 技术篇 - 通过pyminifier库实现源码压缩、混淆、加密保护实例演示,pyminifier的使用方法

發布時間:2025/4/16 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Python 技术篇 - 通过pyminifier库实现源码压缩、混淆、加密保护实例演示,pyminifier的使用方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

源代碼如下:

參數 -O :混淆所有函數/方法名、變量和類。默認是不要混淆。

我這里使用參數 -O 進行源碼混淆。

如果運行時報錯:UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 54: illegal multibyte sequence
可以查看解決方法:
Python 技術篇 - 修改 pyminifier 庫源碼解決編碼不一致導致的報錯問題

轉換后生成新文件,minified 文件夾里也是轉化后的內容,這個是默認生成的,通過參數 -d 可以進行指定。

可以看到方法和變量名都被改了,而且注釋也被默認去掉了,這樣就一定程度上提高了我們源代碼的安全性。
當然默認會被編碼為 gbk ,如需調整可以自行轉化一下文件編碼。

pyminifier 詳細命令方法如下:

pyminifier -h Usage: pyminifier [options] "<input file>"Options:--version show program's version number and exit-h, --help show this help message and exit-o <file path>, --outfile=<file path>Save output to the given file.-d <file path>, --destdir=<file path>Save output to the given directory. This option isrequired when handling multiple files. Defaults to'./minified' and will be created if not present.將輸出保存到給定的目錄。當處理多個文件時,此選項是必需的。默認為'./minified',如果不存在,將被創建。--nominify Don't bother minifying (only used with --pyz).--use-tabs Use tabs for indentation instead of spaces.使用制表符代替空格來縮進。--bzip2 bzip2-compress the result into a self-executing pythonscript. Only works on stand-alone scripts withoutimplicit imports.以bzip2方式壓縮將結果到一個自動執行的python腳本中。只能在獨立腳本上工作,不需要隱式導入。--gzip gzip-compress the result into a self-executing pythonscript. Only works on stand-alone scripts withoutimplicit imports.以gzip方式壓縮結果到一個自執行的python腳本中。只能在獨立腳本上工作,不需要隱式導入。--lzma lzma-compress the result into a self-executing pythonscript. Only works on stand-alone scripts withoutimplicit imports.以lzma方式壓縮將結果到一個自動執行的python腳本中。只能在獨立腳本上工作,不需要隱式導入。--pyz=<name of archive>.pyzzip-compress the result into a self-executing pythonscript. This will create a new file that includes anynecessary implicit (local to the script) modules.Will include/process all files given as arguments topyminifier.py on the command line.-O, --obfuscate Obfuscate all function/method names, variables, andclasses. Default is to NOT obfuscate.--obfuscate-classes Obfuscate class names.--obfuscate-functionsObfuscate function and method names.--obfuscate-variablesObfuscate variable names.--obfuscate-import-methodsObfuscate globally-imported mouled methods (e.g.'Ag=re.compile').--obfuscate-builtins Obfuscate built-ins (i.e. True, False, object,Exception, etc).--replacement-length=1The length of the random names that will be used whenobfuscating identifiers.--nonlatin Use non-latin (unicode) characters in obfuscation(Python 3 only). WARNING: This results in someSERIOUSLY hard-to-read code.--prepend=<file path>Prepend the text in this file to the top of ouroutput. e.g. A copyright notice.

喜歡的點個贊?吧!

總結

以上是生活随笔為你收集整理的Python 技术篇 - 通过pyminifier库实现源码压缩、混淆、加密保护实例演示,pyminifier的使用方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。