I was wondering if the following hashing technique can easily be reversed?

If someone got hold of the hashed value, can he/she reverse it?

Partiuclarly I'm talking about the following code:

hashCode = function(s){
  return s.split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0);              

I'm looking to hash some email addresses.

  • 1
    Your question should contain all info necessary for answering - please edit it and provide the algorithm.
    – guntbert
    Jan 30, 2019 at 22:19
  • I can simply say that it is not designed for security.
    – kelalaka
    Jan 30, 2019 at 22:28
  • In addition to your question not being self-contained, I'm not actually sure whether you're refering to the code-snippet in the SO post, or the code in the link in the SO post. Can you please edit your question to be self-contained? Jan 30, 2019 at 22:56
  • 2
    What do you want this hash for? To make a hash table? To secure a password? Your concern is only that the original data is found, or would a collision also be equally bad?
    – Ángel
    Jan 30, 2019 at 23:08
  • 1
    If you're thinking you can anonymize email address information using a hash function, then you're wrong. (And I assume that is what you're doing. Otherwise you would have posted to StackOverflow.) Things like email addresses, phone numbers, license plates, etc. can be discovered even if all you have is a hash. Jan 31, 2019 at 13:54

2 Answers 2


Generally "hashing" is not reversible. The hash does not contain information to reconstruct the input.


The result doesn't contain enough bits to even be theoretically possible to recover the original input, but note that it's trivial to find some preimage for any given output hash. For example, if you hash [email protected] to 266228007 and I have just that number, it's easy to find that the string !#+6%4# also hashes to 266228007.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .