iex
05/03/2020, 12:49 PMval digest = MessageDigest.getInstance("SHA-256")
digest.update("bar".toByteArray())
val str = digest.digest().toString(UTF_8)
val digest2 = MessageDigest.getInstance("SHA-256")
digest2.update("sldkjfskfjs".toByteArray())
val str2 = digest2.digest().toString(UTF_8)
// str == str2 --> true!
Jakub Pi
05/03/2020, 2:27 PMiex
05/04/2020, 1:36 PMtoString()
?iex
05/04/2020, 1:39 PMString
factory method: String.create(bytes, encoding)
iex
05/04/2020, 1:44 PMstr
, modifying this instance and then "capturing" the second part.iex
05/04/2020, 1:45 PMString.create
and calling reset
on digest
don't help, apparently. It's still true
Jakub Pi
05/04/2020, 2:07 PMJakub Pi
05/04/2020, 2:16 PMval digestArray = digest.digest("bar".toByteArray())
iex
05/04/2020, 11:16 PMupdate
. This code is from a third party library.iex
05/04/2020, 11:16 PMJakub Pi
05/05/2020, 12:48 PMArrays.equals(arr1, arr2)
araqnid
05/05/2020, 3:33 PMMessageDigest.getInstance
returns a new instance of a digester, not a singleton. Afaik, update
should effectively append, i.e. it consumes more data and updates the digest.araqnid
05/05/2020, 3:34 PMarr1 contentEquals arr2
in Kotlinaraqnid
05/05/2020, 3:36 PMJakub Pi
05/05/2020, 4:32 PMJakub Pi
05/05/2020, 4:59 PMiex
05/06/2020, 3:08 PMiex
05/06/2020, 3:08 PM