go: use last 5 hash characters for short urls

This commit is contained in:
lassulus 2021-04-30 11:29:24 +02:00
parent 0f21f4250a
commit a9da6e0e5b

View File

@ -51,7 +51,7 @@ let
sha256=$(echo "$uri" | sha256sum -b | cut -d\ -f1)
base32=$(${pkgs.nixStable}/bin/nix-hash --to-base32 --type sha256 "$sha256")
base32short=$(echo "$base32" | cut -b-5)
base32short=$(echo "$base32" | cut -c48-52)
${pkgs.redis}/bin/redis-cli set "$base32short" "$uri" >/dev/null
ref="http://$req_host/$base32short"