python如何加密_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.pys

[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.pys'

[root@localhost 桌面]# python hello.pyc

hello world...

[root@localhost 桌面]#

--------------------------------------------------------------------------

加密后只能使用python来执行脚本否则不成功

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值