【问题标题】:swift ios 8.0 RSA encryption (known publicKey)swift ios 8.0 RSA 加密(已知 publicKey)
【发布时间】:2020-06-29 06:38:34
【问题描述】:

我正在尝试使用 RSA 加密字符串,我已经从服务器获得了一个 publicKey(String type)。 我如何在没有“SecKeyCreateWithData”的情况下获取 secKey,因为此方法仅支持 ios10+ ?但它必须支持到ios8.0+。

   if #available(iOS 10.0, *) {
        guard let secKey = SecKeyCreateWithData(data as CFData, attributes, &error) else {
            print(error.debugDescription)
            return nil
        }
    } else {
        //how can I do here?
    }

【问题讨论】:

    标签: ios swift encryption rsa public-key-encryption


    【解决方案1】:

    CoreCryptoSecurity 似乎只支持从 iOS 10 开始(如您所见)。

    你有两个选择:

    1) 手动生成 RSA 组件,滚动您自己的实现(建议您避免这种方法)。

    2) 切换到现代跨平台加密库,例如钠。 (不支持 RSA,所有基于 EC 的非对称加密)。

    Apple 也有 CryptoKit,但不支持 iOS 13。

    如果您添加一些关于您的用例的额外信息,我会很乐意建议更多选项。

    【讨论】:

      猜你喜欢
      • 2014-04-29
      • 1970-01-01
      • 1970-01-01
      • 2021-05-08
      • 2013-04-04
      • 1970-01-01
      • 2014-08-16
      • 2013-08-08
      • 1970-01-01
      相关资源
      最近更新 更多