go: use last 5 hash characters for short urls

This commit is contained in:
lassulus 2021-04-30 11:29:24 +02:00 committed by makefu
parent 329d01a7bf
commit 4f638ddb3d
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225

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"