Hashing issue between guava versions

I was using guava 14 to do String hashing like so:



 just upgraded to guava16,

calling this function:

Hashing.sha256().newHasher().putString("String", Charsets.UTF-8).hash().toString()

gives me a different result.



I suspect that the old version was using default charset, but switching Charsets on guava16 doesn’t give me the same result as in guava14. What did I do wrong here?


As stated in the docs of Guava 15, the replacement for the old putString(String) method is putUnencodedChars.




Leave a Reply

Your email address will not be published. Required fields are marked *