-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hashing algorithm changed without mentioning and caused Multiple Exposures #75
Comments
Hi, @levochkaa. Thank you for providing the detailed information. We will review it and get back to you. |
We just checked the hash in different versions of the latest Growthbook SDKs and received the same result as in Swift SDK. So it seems to be working as expected. Did you try another latest SDK, and did you get a different result? |
The hashing didn't change after 1.0.49 release, as I see in git commits history, so I am comparing 1.0.48 (oldHash) vs 1.0.49 (newHash)
Can you share what versions you were comparing, how, and what are the results? |
Hi, @levochkaa. Sure, here is example of running that using the Java SDK. |
We are going to test some features through JS SDK, so I wanted to make sure, that the changed hash is correct now. function hashFnv32a(str: string): number {
let hval = 0x811c9dc5;
const l = str.length;
for (let i = 0; i < l; i++) {
hval ^= str.charCodeAt(i);
hval +=
(hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24);
}
return hval >>> 0;
}
export function hash(
seed: string,
value: string,
version: number
): number | null {
// New unbiased hashing algorithm
if (version === 2) {
return (hashFnv32a(hashFnv32a(seed + value) + "") % 10000) / 10000;
}
// Original biased hashing algorithm (keep for backwards compatibility)
if (version === 1) {
return (hashFnv32a(value + seed) % 1000) / 1000;
}
// Unknown hash version
return null;
}
const seed = "seed"
const value = "value"
console.log(`version 1 - ${hash(seed, value, 1)}`)
console.log(`version 2 - ${hash(seed, value, 2)}`) The output is:
Which matches the new hash in 1.0.49 in iOS SDK, so, thanks for the fix, but this really should be mentioned somewhere (in readme, release notes). |
Hi, @vazarkevych, didn't see your reply about Java SDK. I think the issue is closed, consider mentioning the change in release notes, thank you. |
We have updated GrowthBook SDK from 1.0.48 to 1.0.61, because of this fix #74
But got another problem:
After some investigation, we've found, that:
I've made a quick test to check if the hashing really changed:
The output is:
Yes, hashing changed.
The text was updated successfully, but these errors were encountered: