diff options
| -rw-r--r-- | README.md | 1 | ||||
| -rwxr-xr-x | usergen | 20 |
2 files changed, 15 insertions, 6 deletions
@@ -51,7 +51,6 @@ to `slcl`. If required, encryption should be done before uploading e.g.: using (provided as a `git` submodule by `slweb`). - [`slweb`](https://gitea.privatedns.org/xavi/slweb) (provided as a `git` submodule). -- `xxd` (for [`usergen`](usergen) only). - `jq` (for [`usergen`](usergen) only). - CMake (optional). @@ -7,6 +7,16 @@ usage() echo "$0 <dir>" } +to_hex() +{ + od -An -t x1 | tr -d ' ' +} + +to_bin() +{ + sed -e 's,\([0-9a-f]\{2\}\),\\\\\\x\1,g' | xargs printf +} + if [ $# != 1 ]; then usage >&2 exit 1 @@ -44,17 +54,17 @@ echo "Quota, in MiB (leave empty for unlimited quota):" >&2 read -r QUOTA QUOTA="$(printf '%d' "$QUOTA")" -PWD=$(printf '%s' "$PWD" | xxd -p | tr -d '\n') -SALT=$(openssl rand 32 | xxd -p | tr -d '\n') -KEY=$(openssl rand 32 | xxd -p | tr -d '\n') -PWD=$(printf '%s%s' $SALT "$PWD") +PWD=$(printf '%s' "$PWD" | to_hex) +SALT=$(openssl rand -hex 32) +KEY=$(openssl rand -hex 32) +PWD=$(printf '%s%s' "$SALT" "$PWD") ROUNDS=1000 for i in $(seq $ROUNDS) do printf "\r%d/$ROUNDS" $i >&2 - PWD=$(printf '%s' "$PWD" | xxd -p -r | sha256sum | cut -d' ' -f1) + PWD=$(printf '%s' "$PWD" | to_bin | sha256sum | cut -d' ' -f1) done echo >&2 |
