0
点赞
收藏
分享

微信扫一扫

Python编程:使用os.urandom生成Flask的SECRET_KEY


方法比较简单

import os
import base64

# 生成32位随机字符
a = os.urandom(32)

# 编码为base64
base64.b64encode(a)
Out[13]:
b'2QDq4HSpT8U4W6iZ2xDzGW3CcY2WVsJXVEwYv0qludY='

命令行中使用

python -c 'import base64;import os;print(base64.b64encode(os.urandom(32)).decode())'


参考:
​​Flask】一种生成SECRET_KEY的方法​​




举报

相关推荐

0 条评论