summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/hashPassword/default.nix
blob: 3c604be80edc6bae2379be9923384fb9a2ad27ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{ 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" "$@"
''