Skip to content

Instantly share code, notes, and snippets.

@isaactzab
Created March 20, 2019 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaactzab/e1d3baca80dd5714bee23a559a13ef4e to your computer and use it in GitHub Desktop.
Save isaactzab/e1d3baca80dd5714bee23a559a13ef4e to your computer and use it in GitHub Desktop.
Generate passwords / hash from string / random string - Terminal OSX (with some adjusments will you run in linux)
#!/bin/sh
# usage:
# 1- First argument: String seed
# 2- Second argument: Hash length
# $hashify "my string seed" 10
LENGTH_STRING=${2:-8}
SEED_STRING=$1
md5 <<< ${SEED_STRING} | base64 | awk -v lenstr="$LENGTH_STRING" '{print substr ($0, 10, lenstr)}'
#!/bin/sh
LC_ALL=C tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' </dev/urandom | head -c 13 ; echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment