```fun encryptData(dataDes: String): String? { ...
# multiplatform
t
Copy code
fun encryptData(dataDes: String): String? {
        return try {
            val c = Cipher.getInstance(""RSA/ECB/OAEPPadding")
            c.init(Cipher.ENCRYPT_MODE, Key.rsaPublicKey())
            val encryptOut = c.doFinal(dataDes.toByteArray())

            org.bouncycastle.util.encoders.Base64.toBase64String(encryptOut)
        } catch (e: Exception) {
            Log.d("error:", "error")
            ""
        }
    }

 private fun loadPublicKey(): PublicKey? {
        val rsaPublicKey = runBlocking {
            RuguDataStore.instance.getRsaPublicKey()?.publicKey
        }
        val data = Base64.decode(rsaPublicKey)
        val spec = X509EncodedKeySpec(data)
        val fact = KeyFactory.getInstance(Algorithm.RSA)
        return fact.generatePublic(spec)
} Can I convert to code android to kotlin mutilplatform ? I encrypt puclickey asymmetric encryption. I used lib but the results encryptData() could not decode. Looking forward to everyone's help.