Closed GoogleCodeExporter closed 9 years ago
I was wrong with my last sentence; appending works too (it creates a suffix
code instead of a prefix code).
It might make sense to provide a hasher taking care of this. Simply calling
Hashing.protectedHasher(Hashing.sha1().newHasher()).putString(s1).putString(s2);
would guarantee a unique `HashCode` over all strings `s1` and `s2` until
somebody breaks SHA1.
It can't protect against everything, it just handles the most common case
(strings and byte arrays).
I'd say it really should accept nulls. Otherwise the user might lose uniqueness
too easily by writing
if (s1!=null) hasher.putString(s1);
if (s2!=null) hasher.putString(s2);
Original comment by Maaarti...@gmail.com
on 13 Nov 2012 at 9:44
Thanks for the suggestions Martin! I've updated the docs internally (should be
mirrored out soon).
I'm also going to re-file this as a feature request for a "protected" (not sure
if that's the right name?) Hasher wrapper.
Original comment by kak@google.com
on 13 Nov 2012 at 5:11
This issue has been migrated to GitHub.
It can be found at https://github.com/google/guava/issues/<id>
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:13
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:18
Original comment by cgdecker@google.com
on 3 Nov 2014 at 9:08
Original issue reported on code.google.com by
kak@google.com
on 13 Nov 2012 at 12:11