guava icon indicating copy to clipboard operation
guava copied to clipboard

A way to get a HashFunction backed by a MessageDigest algorithm

Open kevinb9n opened this issue 3 years ago • 11 comments

Another way to satisfy #3960

kevinb9n avatar Mar 28 '22 15:03 kevinb9n

Is MessageDigest the same as MD5 algo?

ritikBhandari avatar Mar 28 '22 15:03 ritikBhandari

MessageDigest includes, but is not limited to, MD5.

lowasser avatar Mar 28 '22 17:03 lowasser

mdalgo

Among these, which MD algo do we have to back HashFunction with? and which one are we currently using?

ritikBhandari avatar Mar 28 '22 18:03 ritikBhandari

HashFunction is an interface with many implementations, including those three (Hashing.md5(), Hashing.sha1(), Hashing.sha256()). Those three are backed by MessageDigest; the others are not.

lowasser avatar Mar 28 '22 18:03 lowasser

The point is that we don't expose a utility in general to allow any MessageDigest algorithm to be used as a HashFunction.

lowasser avatar Mar 28 '22 18:03 lowasser

HashFunction is an interface with many implementations, including those three (Hashing.md5(), Hashing.sha1(), Hashing.sha256()). Those three are backed by MessageDigest; the others are not.

So now do we have to back the other ones as well according to the issue raised?

ritikBhandari avatar Mar 28 '22 18:03 ritikBhandari

No, there's no plan to change other implementations of HashFunction. This issue is just about whether or not we should expose a way to make a HashFunction from any MessageDigest.

lowasser avatar Mar 28 '22 18:03 lowasser

Okay! Got it. Thank you :)

ritikBhandari avatar Mar 28 '22 18:03 ritikBhandari

@cpovirk Is there any documentation as to what label P3 means?

nkkolluru avatar Apr 08 '22 21:04 nkkolluru

hello! Is the decision to add new API method(s) to Hashing, to support creating a HashFunction from any MessageDigest algorithm taken? Would there be a design process?

nkkolluru avatar Apr 08 '22 21:04 nkkolluru