3 ms·
My version of `pw', might be useful to those without `pwgen': function genpasswd() { openssl rand 150 | LC_CTYPE=C tr -dc '[[:alnum:]!@#$%^&]' | tr -d i
by gav 5y ago
My version of `pw', might be useful to those without `pwgen':
function genpasswd() {
openssl rand 150 | LC_CTYPE=C tr -dc '[[:alnum:]!@#$%^&]' | tr -d iIlLOo0 | cut -c 1-${1:-12};
}
- nickjj 5y agoOh yeah I forgot to mention in the alias comment that it depends on pwgen. Thanks for the reminder, I just updated it. I made a whole video on generating random password from the command line and compared a few options (including using openssl) at: https://nickjanetakis.com/blog/generate-a-random-secure-password-on-the-command-line-with-pwgen https://nickjanetakis.com/blog/generate-a-random-secure-pass... The TL;DR for not using openssl is that you're not going to get the same amount of characters every time. For example if you run yours with 48 characters instead of 12 it won't generate 48 characters every time you run it. With pwgen (something you can apt or brew install) you know what you're getting every time.
- gav 5y agoIf you change `openssl rand 150` to a bigger number, say 1000 or so, you can generate longer passwords.
- nickjj 5y agoAh, I see. Did you test your solution on macOS btw? I know macOS uses an ancient version of Bash and has different binaries that act differently vs Linux (such as sed). I don't have a Mac here but I do try to make my dotfiles compatible with it. If your solution works on macOS it would be nice to drop the pwgen dependency.
- gav 5y agoI use it on macOS and it works fine. There is a brew recipe for pwgen, but that's one more dependency to worry about.