Sunday, November 17, 2013

Generate random alphanumeric strings for passwords

Here's a few

# date +%s | sha256sum | base64 | head -c 32 ; echo

# openssl rand -base64 32

# tr -cd '[:alnum:]' < /dev/urandom | fold -w30 | head -n1

# strings /dev/urandom | grep -o ':alnum:' | head -n 30 | tr -d '\n'; echo

And to easily access them, load them into your profile as a function

randpw() {
   len=$1
   if [ -z $len ]; then
      len=12
   fi
   date +%s | sha256sum | base64 | head -c $len; echo;
}

No comments: