Zpkgs krebs: add hashPassword

This commit is contained in:
tv 2015-07-24 23:16:48 +02:00
parent 13cc704c60
commit 311e837c91
2 changed files with 17 additions and 0 deletions

View File

@ -8,4 +8,5 @@ pkgs //
{
github-hosts-sync = callPackage ./github-hosts-sync.nix {};
github-known_hosts = callPackage ./github-known_hosts.nix {};
hashPassword = callPackage ./hashPassword.nix {};
}

View File

@ -0,0 +1,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"
''