From 5926594690f03cf282b856cc53facbea8a42d88c Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Thu, 25 Apr 2019 08:49:30 +0800 Subject: Add unix/gen-pass.sh: generate random passwords --- unix/gen-pass.sh | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100755 unix/gen-pass.sh diff --git a/unix/gen-pass.sh b/unix/gen-pass.sh new file mode 100755 index 0000000..4718b0c --- /dev/null +++ b/unix/gen-pass.sh @@ -0,0 +1,81 @@ +#!/bin/sh +# +# Copyright (c) 2019 Aaron LI +# MIT License +# +# Generate random passwords. +# +# Credit: +# * How to generate a random string? +# https://unix.stackexchange.com/a/230676 +# * password-store: +# http://www.passwordstore.org/ +# + +# usage: generate ${characters} ${length} +generate() { + local characters="$1" + local length="$2" + env LC_ALL=C tr -dc "${characters}"