diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2023-01-22 02:21:30 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2023-02-28 01:43:59 +0100 |
| commit | 08a38aea94f3247fe1334db46b45d74ebaeef892 (patch) | |
| tree | 0ef91165c7ce9a86222f9945af48617d91bcb28a | |
| parent | 1b990951f550f042466799325f2c5bd260893ac5 (diff) | |
| download | slcl-08a38aea94f3247fe1334db46b45d74ebaeef892.tar.gz | |
Add usergen
This script takes a username and password from standard input and
generates a JSON object that can be appended to the "users" object in
db.json.
| -rwxr-xr-x | usergen | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -0,0 +1,29 @@ +#! /bin/sh + +echo Username: >&2 +read -r USER +echo Password: >&2 +read -r PWD + +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) + +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) +done + +echo >&2 +cat <<-EOF +{ + "name": "$USER", + "password": "$PWD", + "salt": "$SALT", + "key": "$KEY" +} +EOF |
