mkodekar / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

HashCode.fromString() expects string with an even number of characters #1807

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
HashCode.fromString() expects an even number of characters, making it 
impossible to get the hash of a string like "foo".

HashFunction.hashString() does not have this limitation. In my opinion, the 
above mentioned function shouldn't have it either.

Original issue reported on code.google.com by aried3r on 17 Jul 2014 at 5:58

GoogleCodeExporter commented 9 years ago
These methods are for completely different purposes.  HashCode.fromString is 
only supposed to take a hexadecimal-encoded string of bytes, which by 
definition has even length.  It is *not* a function to "hash a string": its 
input should already be a hash, in a particular format.

Original comment by lowas...@google.com on 17 Jul 2014 at 6:02

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 17 Jul 2014 at 6:06

GoogleCodeExporter commented 9 years ago
Completely missed that while reading the docs, even though it clearly says so. 
My bad, thanks for the quick reply.

Original comment by aried3r on 17 Jul 2014 at 6:10

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<issue id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:08

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:07