I have this compress/hash function (compresses a string into a short number)
function compress(input) {
let output = 0;
for (let i=0; i < input.length; i++) {
output = (output << 5) - output + input.charCodeAt(i)
output &= output;
}
return output;
}
Now I'm searching for an algorithm where i can input a number and then get a string back (I'm not searching for the original string). This String should produce the same hash wen compressing it again.
Example
let compress1 = compress("Hello") // => 69609650
let deob = expand(compress1) // => ??
let compress2 = compress(deob) // => 69609650
compress1 === compress2 // should be true
One idea i had, i cloud just try out random strings and then save the output with the input in a key-value map, but this would take some time. Is there an more efficient way to find a string that produces the same hash (for a given hash)?