首页 > 系统相关 >python和shell产生随机密码,哪个更方便

python和shell产生随机密码,哪个更方便

时间:2022-11-11 11:01:08浏览次数:37  
标签:shell string python random 密码 随机 words ascii

一、Python

# @File : 生成随机密码.py
# @desc :
import string
import random

####侯选
all_words = list(string.ascii_lowercase +string.ascii_uppercase + string.digits + string.punctuation)

###随机打散
random.shuffle(all_words)

###得到密码
#print("".join(all_words))
#如: h3(W*e.'6ik1{JGYtuS5sjqA,Xnrv7|IloQ>";+TF8HC!~0&KN}cMVEOz_gR)=?/P@d#w:Uba-[\%p9xD2<4Bmf`]^$yZL

print("".join(all_words[:20]))

 

二、Shell

< /dev/urandom tr -dc _A-Z-a-z-0-9#+@^$% |head -c32;echo

 

标签:shell,string,python,random,密码,随机,words,ascii
From: https://www.cnblogs.com/chinaops/p/16879878.html

相关文章