summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/hashPassword/default.nix
blob: 6a7c51c57edeb7e12a9d955db919c4dc3a50bc77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{ lib, pkgs, ... }:

pkgs.writeScriptBin "hashPassword" ''
  #! /bin/sh
  # 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"
''