summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/hashPassword/default.nix
blob: 3da65ad7919006be37b8c5257f81b0222727434f (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"
''