Easy command line password generation

A quickie, but it's quite handy for me.

Often I want a new password for something. I use 1password to store passwords (and I hope you're using a similar tool), and it's great, but it doesn't have much of a command line tool. Sometimes I just want a quick password, and the terminal is sure handy otherwise, so it'd be nice to have this, too.

Note: There is a 1password command line tool, it just doesn't serve this purpose well.

Option 1: OpenSSL

OpenSSH is a handy tool and it can output some great random strings, almost as if it was made for this purpose (hint: it essentially is for this purpose):

openssl rand -base64 12

This will give you a nice, 12 character string, looking something like:


You can also fiddle with the encoding to get different types of strings (-hex instead of -base64, for instance).

Option 2: md5

One of the reasons I like having a Mac is that there should be easy ways to do things whenever possible. OpenSSL is awesome, and probably better in most technical ways, but if I want something just quick, easy, and reasonable, I take a shorter path to get there:

date | md5

Really, anything can go into the md5 function, but using date as a seed changes every second and produces decent results without needing to think of much, like:


Now, MD5 is a bad way to store passwords, but being used to generate passwords is still fairly useful.


Are these great for everything? Not really, but for a quick random string for general use, I've found it quite handy.