In the "Small Collision Probabilities" section of https://preshing.com/20110504/hash-collision-probabilities/ you can see the trade-offs depending on how big the hash value is. Rather a 32-bit or 160-bit hash depends on your use-case and limitations.
How can I construct a checksum/hash of n-bits given the integer n?
The idea is that the caller of the hash function can determine the trade off that fit their need (only want to store integers and dont care about collisions, use 32 bit, etc).
The probability of collisions should be on-par with typical hash functions of the same bit-length (Given n = 160, the probability of collisions is close to sha-1. Given n = 32 the probability of collisions is close to crc-32)
My attempt:
if n < 160, sha-1(input) truncate first bits to bit-size n.
if n = 160, sha-1(input)
if n > 160, sha-1(input) & sha-1(input) [Repeat concatenation (n % 160) times and then truncate bits to n)
I realize that for n > 160
my collision probability isn't getting any lower because its performing the same hash. Also sha-1 isn't needed because my purpose is not cryptographic in nature and more of a checksum