-
Notifications
You must be signed in to change notification settings - Fork 965
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
Translated Guava Hashing implementation returns different values when called successively #797
Comments
I'm away from my desk until Monday, but reviewing the code I think I see the problem. In IosSHAMessageDigest.java, line 66, the initial digest buffer is declared on the stack but not cleared, so its initial values are likely to differ between invocations (depending on what was previously on the stack). If you have a local j2objc build and have time to experiment, try adding a memset() call after the digest declaration and before the CC_SHA1() call:
|
Thanks for looking into this. I won't have time today but will update here if I get a chance to try the fix. |
The |
Change on 2016/09/28 by tball <tball@google.com> ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=134560133
Fixed in current source. |
I've found this method returns different values when called successively, using j2objc v1.1. The same method returns consistent values in Java (tested on Android).
public static String testHash(String input) {
byte[] bytes = input.getBytes("UTF-8");
return Hashing.sha1().hashBytes(bytes).toString();
}
assert(testHash("foo").equals(testHash("foo")) == true);
The text was updated successfully, but these errors were encountered: