nix-files/hosts/modules/derived-secrets/hash-path-with-salt

13 lines
267 B
Plaintext
Raw Normal View History

#!/usr/bin/env nix-shell
#!nix-shell -i bash
2023-07-08 11:20:00 +00:00
file="$1"
enc="$2"
2023-07-11 05:15:56 +00:00
nibbles="$3"
2023-07-08 11:20:00 +00:00
echo "$file" | cat /dev/stdin /etc/ssh/host_keys/ssh_host_ed25519_key \
| sha512sum \
2023-07-11 05:15:56 +00:00
| cut -c "1-$nibbles" \
| tr a-z A-Z \
| basenc -d --base16 \
2023-07-08 11:20:00 +00:00
| basenc "--$enc" \
> "$file"