![](/img/trans.png)
[英]ASP.Net equivalent of openssl_private_decrypt and openssl_pkey_get_private
[英]What is Kotlin equivalent of funtion openssl_private_decrypt?
我在基於PHP的服務器中使用openssl_public_encrypt
函數來加密帶有公鑰的消息。 加密的消息被發送到基於Kotlin的服務器。 如果是在PHP中,則可以使用openssl_private_decrypt
進行解密。 如何在Kotlin中解密消息?
所以我在Kotlin找到了相同的代碼:
private fun decrypt(cryptedData: ByteArray): String {
val cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding") //"PKCS1Padding" is the default padding
cipher.init(Cipher.DECRYPT_MODE, key)
val res = cipher.doFinal(cryptedData).toHexString()
val decrypted = hexToAscii(res)
return decrypted
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.