stockholm/krebs/5pkgs/simple/hashPassword/default.nix
2018-04-05 17:34:17 +02:00

16 lines
297 B
Nix

{ lib, pkgs, ... }:
pkgs.writeDashBin "hashPassword" ''
# usage: hashPassword [...]
set -euf
export PATH=${lib.makeBinPath (with pkgs; [
coreutils
mkpasswd
openssl
])}
salt=$(openssl rand -base64 16 | tr -d '+=' | head -c 16)
exec mkpasswd -m sha-512 -S "$salt" "$@"
''