summaryrefslogtreecommitdiffstats
path: root/Zpkgs/krebs/hashPassword.nix
blob: a10340cc4d5de2f35f0fded2c53912b50b67c25b (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.makeSearchPath "bin" (with pkgs; [
    coreutils
    mkpasswd
    openssl
  ])}

  salt=$(openssl rand -base64 16 | tr -d '+=' | head -c 16)
  exec mkpasswd -m sha-512 -S "$salt"
''