我使用以下代码将数据转换为swift中的String。返回的String为nil。你能帮我辨别出什么问题吗?谢谢。
let dataObject = try RSAUtils.encryptWithRSAPublicKey(str: textToEncrypt!, pubkeyBase64: pubKeyB64)
let dataToString = String(data: dataObject!, encoding: String.Encoding.utf8) as String!
答案 0 :(得分:3)
此基础64由RSAUtils lib加密数据,所以使用此
if ( dataObject != nil ) {
let encryptedDataText = dataObject!.base64EncodedString(options: NSData.Base64EncodingOptions())
NSLog("Encrypted with pubkey: %@", encryptedDataText)
}