python 如何加密自己的脚本
----------------------------脚本部分---------------------------------
[root@localhost 桌面]# cat hello.py
#!/usr/bin/env python
print "hello world..."
--------------------------测试部分-----------------------------
[root@localhost 桌面]# chmod a+x hello.py
[root@localhost 桌面]# ./hello.py
hello world...
[root@localhost 桌面]# Python hello.py
hello world...
---------------------------加密部分--------------------------
//使用以下命令加密加密后会生成一个pyc的文件那就是你脚本的加密文件
[root@localhost 桌面]# python -m py_compile hello.py
[root@localhost 桌面]# ls
hello.py hello.pyc
[root@localhost 桌面]#
-------------------------加密后测试--------------------------
[root@localhost 桌面]# cat hello.pyc
X}Tc@s dGHdS(shello world...N((((hello.py<module>s
[root@localhost 桌面]# chmod +x hello.pyc
[root@localhost 桌面]# ./hello.pyc
: command not found:
./hello.pyc: line 2: syntax error near unexpected token `('
./hello.pyc: line 2: `X}Tc@s dGHdS(shello world...N((((hello.py<module>s'
[root@localhost 桌面]# python hello.pyc
hello world...
[root@localhost 桌面]#
--------------------------------------------------------------------------
加密后只能使用python来执行脚本否则不成功
相关文章