Mod
02/07/2023, 6:09 AMexpect object EncryptionHelper {
fun md5(input: String): String
}
this is the Android part:
import java.math.BigInteger
import java.security.MessageDigest
actual object EncryptionHelper {
actual fun md5(input: String): String {
val md = MessageDigest.getInstance("MD5")
return BigInteger(1, md.digest(input.toByteArray())).toString(16).padStart(32, '0')
}
}
ephemient
02/07/2023, 6:34 AM.toString(16)
looks suspiciously wrong to me… you'd need to .padStart(2, '0')
or change how the string representation is generated)ephemient
02/07/2023, 6:35 AMCC_SHA256
with CC_MD5
of course, but it works the same wayMod
02/07/2023, 6:36 AMephemient
02/07/2023, 6:39 AMfun UByteArray.toHexString(): String = buildString(size * 2) {
for (ubyte in this@toHexString) {
append((ubyte.toInt() shr 4 and 15).digitToChar(radix = 16))
append((ubyte.toInt() and 15).digitToChar(radix = 16))
}
}
Mod
02/07/2023, 6:41 AMjessewilson
02/07/2023, 12:42 PMMod
02/09/2023, 6:38 AM