Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
Reverse hash function to get same output

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)?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!