stockholm/krebs/5pkgs/simple/hashPassword/default.nix

16 lines
305 B
Nix
Raw Normal View History

2015-07-24 23:16:48 +02:00
{ lib, pkgs, ... }:
2022-11-21 23:58:35 +01:00
pkgs.writers.writeDashBin "hashPassword" ''
2018-04-05 17:34:17 +02:00
# usage: hashPassword [...]
2015-07-24 23:16:48 +02:00
set -euf
2016-03-03 19:45:46 +01:00
export PATH=${lib.makeBinPath (with pkgs; [
2015-07-24 23:16:48 +02:00
coreutils
mkpasswd
openssl
])}
salt=$(openssl rand -base64 16 | tr -d '+=' | head -c 16)
2018-04-05 17:34:17 +02:00
exec mkpasswd -m sha-512 -S "$salt" "$@"
2015-07-24 23:16:48 +02:00
''