CryptoCompare.kt

539 B · raw

1package com.peachpasswords.sync23import java.security.MessageDigest45/**6 * Fixed-format protocol comparisons. Wire-format length is public, but the7 * contents are compared without a data-dependent early exit.8 */9internal object CryptoCompare {10    fun utf8(left: String, right: String): Boolean =11        MessageDigest.isEqual(12            left.toByteArray(Charsets.UTF_8),13            right.toByteArray(Charsets.UTF_8),14        )1516    fun hex(left: String, right: String): Boolean =17        utf8(left.lowercase(), right.lowercase())18}