Linux/Mac 密码生成器

文章目录[隐藏]

现在应用越来越多,经常要输入密码,有的对密码的健壮性没有要求,有的需要大小写,特殊字符,数字,至少多少位等等,绞尽脑汁想不到好一点的密码。之前我一直在用 或者 1Password 的密码生成工具来生成密码,但是对于不使用这些密码保存工具的同学来说,难道就真的束手无策了吗?

好在 系统下(我不用 ),我们还是有办法可以生成复合要求的密码的。

openssl

很多人不知道,openssl 其实也有输出随机字符串的功能吧,使用方式如下:

Hzzs-MacBook-Pro:~ hzz$ openssl rand --help
unknown option '--help'
usage: rand [-base64 | -hex] [-engine id] [-out file] num
 -base64            Perform base64 encoding on output
 -engine id         Use the engine specified by the given identifier
 -hex               Hexadecimal output
 -out file          Write to the given file instead of standard output

示例:

Hzzs-MacBook-Pro:~ hzz$ openssl rand -base64 16
NznX5iRP+fZdTlKP7CbcSA==
Hzzs-MacBook-Pro:~ hzz$

pwgen

pwgen 是 Linux 中一款比较专业的密码生成工具,当然也是支持 MacOS 的,安装方式如下:

# Linux
 install -y pwgen

# MacOS
 install pwgen

使用方式:

Hzzs-MacBook-Pro:~ hzz$ pwgen --help
Usage: pwgen [ OPTIONS ] [ pw_length ] [ num_pw ]

Options supported by pwgen:
  -c or --capitalize # 至少一个大写字母
        Include at least one capital letter in the password
  -A or --no-capitalize # 不要包含大写字母
        Don't include capital letters in the password
  -n or --numerals # 至少包含一个数字
        Include at least one number in the password
  -0 or --no-numerals # 不要包含数字
        Don't include numbers in the password
  -y or --symbols # 至少包含一个特殊字符
        Include at least one special symbol in the password
  -r <chars> or --remove-chars=<chars> # 从密码中移除某些字符
        Remove characters from the set of characters to generate passwords
  -s or --secure # 生成完全随机的密码
        Generate completely random passwords
  -B or --ambiguous # 不包含有歧义的字符
        Don't include ambiguous characters in the password
  -h or --help # 帮助信息
        Print a help message
  -H or --sha1=path/to/file[#seed] # 使用指定文件进行加密
        Use sha1 hash of given file as a (not so) random generator
  -C # 以列的方式生成密码
        Print the generated passwords in columns
  -1 # 不以列的方式生成密码
        Don't print the generated passwords in columns
  -v or --no-vowels # 不使用元音字符
        Do not use any vowels so as to avoid accidental nasty words
Hzzs-MacBook-Pro:~ hzz$ 

使用方式如下:

# 直接使用
Hzzs-MacBook-Pro:~ hzz$ pwgen 
ahKies0i IoreiY0s MaiP3aSa Wezooth4 ahjee4Ae iw9Ujah6 dei3iQua Ko5fie7l
Ea5Aipha yei1Peid USo2beup Eic1zega haoSei5T ahshie6V aexauz4E Wear0mo1
ieV1fuh8 euwaiZu7 woh3aNie bi3Oosoo reeYei4u ieko9Vai jaeB4eiv Joog3eet
Mohr1soo eiroh5Ai io3eX7oh wu9xaeVi leiR7iej jah2vuiM aiy2Faem eiG6keej
haiy3iSa eejieS5b EYahm3sh Eiz2ugho au9Aighu hi0Oan0m Oo5eize9 eiM1ooN8
iih0Quoo Adi2eik8 Riy7eeyo aePeere8 iereKaw7 Iniyee6I oTi8Waej uuZ4Aehi
Faequai0 ob1aef7R AemaLoh6 ootho8Lu Poh3heiW Igh4aide vah1EiCo iNg0yoo6
ieDai9ge Ohch9chi hee0Aihi avo1Baiw ain1uVal Gaothai3 Eigh9ies jua9Fae5
za5phiQu geK3co3x eoWin3ai Keeti8ah Looh1agh il4ong3F too3Thae Aecor0Bo
ohJ0Yoo2 iuR8vee7 oNg1eh3t ca0ohY5V Eigh3IeC ieShae7i Viexaeg3 Phief3Ap
Ma2kie8B eifaew5T ead0EiMi vath6Ong Lee7teis mo3ooMie oohoh6Ee She0muth
ku3Quio8 Eerai0Qu QuohRe9x Upee9equ ieM5maiz eT1geema Ahy5xa1o quuf0aiG
joThah3i Mae5Of2e da1soCai us2Vair3 ahJi4em0 Seiya1ui Eim1bahR EiPai8ki
ied6xooR eCh7chee Eosie7zi ZohMaiy3 Uth8Phio uqu1ohYu chah7ohR eipoh6Ee
ohk4eiW5 Ohgh2quu weeD1rah Ugh6oobu Thae5vu3 iab6Ahfa Ongog3ai Show5ais
aghi4Wi9 zoR2jeir OwaWoo6a Noo7mee6 ooYie8li Fi6tooCh gieD1ush ooR7do9o
Foo5eeca Pooy9vu1 ies0OoDo Aeyea6ie Pah5wee1 rae1ohWe aeD3lail ohh5Bah4
Ai5Hahsh yieZ0awa fo2Daedi ohS1jocu gai1Tif9 keeKoh4t Toothoo9 chaiH0Zu
ooQuee1i UCh3Ze1g ier5Kahn Ohghoo8e iu3raC8v wai7Ahc3 Ibai8zai pileGai9
Ga5gahgu Ila7fei9 Aina6thu Ees7lohs ahv8pi9F oopho7Pi Pheilee7 Xohngee1
Hzzs-MacBook-Pro:~ hzz$

# 按需求使用
Hzzs-MacBook-Pro:~ hzz$ pwgen -cnysB 16 
g'mW'hW|9&!.:4$U >73>vx$._hEmdz~i %q7$b(Ab's[P|)>A V7)ouy?C^|U}\"3}
b:7#{]i_Pc^V*Hbm .imXW9=PrgtPiyan $-z7/d*FKyej9Nj< #UVAMEjFUjH3~/<h
>Pms|&FU_pTYf$7) kb^\"4yFEia)K4{V NEze*P4<CwoMgL{C wbakfnU3,xeY#Yxg
?7n+Ltapf)~kpzF= b[vibv.9qR)`|thM ~Jg3#/c39u-dfy-! X:/b7}#J'gTT<H,J
]JC?%7Lhv~o,7(P> viX7;?"wrd."yrqs >gXwa^daickT3YF7 _M="N_f|3(peNu9'
P~?Nox?co?Y9<A]` 9!tpYWA,t->}}#r= y;aNst343J__c>w" j*[?9Pq\Cqa4EPqh
P;7$"m%ju|Xe$Fw% {FP:<!xrFwE4~}3] _,M{4J:wfy\,o!v; r|q=9\(^#iPVYq+%
"CpfJLHC_tcF?9_A u^m>7FHU34%`j>{b qkb>tuMqe|9ef#&V %brhXX?4;Y$|+a{^
tC7tn;CW.KFvKPpP /UmnE4#n<+xm$d][ gru\nTkW#j9#_r>: e7ptEarFF<X4f9x/
sPrigJ_~=7!Uu:uA RmU>3j-Wwjs~T/eY 9m./oYh\VF+fPp/_ >p#t3T&Kp*;}Y[T(
txwmR:#M;[k,_47f hsr>qro=q!7,YHXv q4p3V#m'Ywf;q:W{ ;&@#Uf9>PjK!eCU_
~rg];Nj($U\=9d"C ;n&xYfp\J9&K"zuv ka"3-M<JCa`MW{KR Pj9q4z?EL%Xy;(~[
pzd#fp7<w>mAJ\Tj #npT3'ia{=mLWzW> KET/_3yMo~C|#=<q :3z"!?roc7Cn<W$`
HF4EENR*z9`<?[ys t:3hf>#tpcj(q7R, a4WX}%g!xnq%+"qe '.J-;]n,?9M]fc|m
7E:)WMg%"&(vyV{b Jp/zfR-p(&W4u;`K @t(,$En9Vu;vbH:z Yn<%VRE@rVEzk9[4
q<HKg,a["=.z4mzy {o>-7C{?dqr!x^!F pPNx4c&'Le#qr<|[ Tpb9uki7_!?`#|zj
3kAmni<{AYU]rEUP {c^KyKjv`L&~aA3F }Rht>f`E7M_.#ij% ]=.A3r|\?M\q%?!N
%X#qdp@v*C,#?3R~ _-4'UjVU_cbpNLp& r&%ahaYhn4;Eg*7j u%bz'.V=_#<e"^9E
:)bYo@X;q|=N9{b4 xjiF[Lo:y}%C4(^q ^$7b#me/A$;'APVz z'v$VRJaCxzx3$i,
:4znj|^M|fwH`omJ )L/;qe',Wt.3mp!] MRf#"j@u`Ls4KTWt z/~Hco3"Rs]K-+&c
Hzzs-MacBook-Pro:~ hzz$

最后,再复杂的密码,如果记录在纸上或无加密的文档中,也就跟 123456 无异,建议使用加密文档来保存复杂密码,也可以使用 LastPass 或 1Password 来创建并存储复杂密码。

Linux/Mac 密码生成器

Leave a Reply

Your email address will not be published. Required fields are marked *