I’m looking for a hash algorithm, that when given a 64 bit sequential value, will hash to 8 bits uniformly.
I don’t want to just use the least-significant byte as the hash value.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As a general case of Oli Charlesworth’s solution, you can select coprime with 256 and pre-multiply each byte from your input by that value and then
XORall values together. You’ll still get uniform distribution, but for sequential inputs you’ll get non-sequential output, for instance:For 1, 2, 3, 4, 5, 6, … it will get you 125, 250, 119, 244, 113, 238, etc