【问题标题】:Decrypt OpenSSL encrypted string in objective-c在objective-c中解密OpenSSL加密字符串
【发布时间】:2014-08-12 02:03:48
【问题描述】:

我有一个使用以下代码在 PHP 中加密的字符串

function encrypt($string, $publicKey)
{
    openssl_public_encrypt($string, $cryptedText, $publicKey);
    return base64_encode($cryptedText);
}
$publicKey = file_get_contents('public.crt');
$encryptedText = encrypt('Test', $publicKey);

这在 PHP 中运行良好,我可以使用公钥/私钥对加密/解密。

encryptedText 被发送到我想解密相同字符串的 iOS 应用程序,我尝试了多种方法,但似乎没有任何效果,任何指针都可以执行以下操作。

  • 在 Objective-C 中解密从 PHP 接收到的 OpenSSL 加密字符串
  • 加密并发送数据到 PHP 进行解密(应该支持openssl_private_decrypt

【问题讨论】:

  • 看来this guide 应该足以满足您的需要。
  • 谢谢@Jack 让我试试这个
  • @Ja͢ck,您的链接有帮助,谢谢。

标签: objective-c openssl


【解决方案1】:

我在 iOS 上使用了这个库,效果很好。

https://github.com/jslim89/RSA-Example

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2016-03-19
  • 1970-01-01
  • 2022-11-25
  • 1970-01-01
  • 2010-09-18
  • 1970-01-01
  • 1970-01-01
  • 2010-11-12
相关资源
最近更新 更多