3 # Usage: genpass-monkey [NUM]
5 # Generate a password made of 26 alphanumeric characters
6 # with the security margin of at least 128 bits.
8 # Example password: nz5ej2kypkvcw0rn5cvhs6qxtm
10 # If given a numerical argument, generate that many passwords.
12 emulate -L zsh -o no_unset -o warn_create_global -o warn_nested_var
14 if [[ ARGC -gt 1 || ${1-1} != ${~:-<1-$((16#7FFFFFFF))>} ]]; then
15 print -ru2 -- "usage: $0 [NUM]"
19 zmodload zsh/system || return
22 local -r chars=abcdefghjkmnpqrstvwxyz0123456789
26 sysread -s1 c || return
27 # There is uniform because $#chars divides 256.
28 print -rn -- $chars[#c%$#chars+1]