kasi

POSIX shell password manager that is cryptography program-agnostic
Log | Files | Refs | README | LICENSE

random (501B)


      1 #!/bin/sh
      2 # Simple random string generator for passwords and usernames
      3 # $LEN initial declaration commented out for runtime LEN config
      4 
      5 LC_ALL=C
      6 #LEN=${LEN:-24}
      7 ALPHA="A-Za-z"
      8 NUM="0-9"
      9 SPECIAL='!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~'
     10 
     11 random() {
     12 	</dev/urandom tr -dc "${ALPHA}${NUM}${SPECIAL}" | dd bs=1 count=${LEN:-32} 2>/dev/null ; echo
     13 }
     14 
     15 case $1 in
     16 	pass)
     17 		random ;;
     18 	user)
     19 		LEN=${LEN:-12} SPECIAL='' random ;;
     20 	*)
     21 		printf "Usage: $0 pass|user\nSet LEN environment variable for length" ;;
     22 esac