jeggy
10/31/2019, 1:19 PMjeggy
10/31/2019, 1:31 PMkarelpeeters
10/31/2019, 1:32 PMjeggy
10/31/2019, 1:33 PMmyDataClassInstance.hashCode()
karelpeeters
10/31/2019, 1:35 PMkarelpeeters
10/31/2019, 1:36 PMhashcode
implementation?jeggy
10/31/2019, 1:39 PMabstract string val
and one open var of a enum class
. Other than that my data class only has String
and optional Int val
karelpeeters
10/31/2019, 1:50 PMjeggy
10/31/2019, 1:52 PMkarelpeeters
10/31/2019, 1:53 PMjeggy
10/31/2019, 1:54 PMkarelpeeters
10/31/2019, 1:56 PMDico
10/31/2019, 2:00 PMDico
10/31/2019, 2:00 PMjeggy
10/31/2019, 2:31 PMjeggy
10/31/2019, 2:32 PMjeggy
10/31/2019, 2:32 PMjeggy
10/31/2019, 2:34 PMmd5(data.toString)
?Dico
10/31/2019, 2:55 PM// do not share between threads
class DataHashCtx {
private val md = MessageDigest.getInstance("SHA-1")!!
private val bb = ByteBuffer.allocate(20)!!
fun reset() {
md.reset()
tmpBuf.clear()
}
fun update(value: Int) {
bb.putInt(0, value)
md.update(bb.array(), 0, Int.SIZE_BYTES)
}
fun update(value: String) {
// String hashCode implementation is part of API and unchanged since JDK 1.2
update(value.hashCode())
}
fun hash(): Hash {
md.digest(bb.array(), 0, 20)
// Store 20 bytes in some Hash class.
return hashOf(bb)
}
}
Dico
10/31/2019, 2:55 PMdata class MyData {
fun dataHash(ctx: DataHashCtx): Hash {
ctx.reset()
ctx.update(this.dataItem1)
ctx.update(this.dataItem2)
ctx.update(this.dataItem3)
ctx.update(this.dataItem4)
ctx.update(this.dataItem5)
return ctx.hash()
}
}
Dico
10/31/2019, 2:56 PMAlowaniak
10/31/2019, 6:29 PMjeggy
11/01/2019, 11:21 AM