简体   繁体   English

在Objective c和C#之间使用AES128进行加密/解密

[英]Encryption/ Decryption using AES128 between Objective c and C#

I am using encryption/decryption between Objective c(iPad end) and C#(.net, server site). 我正在目标c(iPad端)和C#(。net,服务器站点)之间使用加密/解密。 I am using code from this link: iPhone/C# AES Encryption 我正在使用此链接中的代码: iPhone / C#AES加密

We are encrypting a XML on server end and sending it to iPad end using web services. 我们正在服务器端加密XML,然后使用Web服务将其发送到iPad端。 At the iPad end when i am trying to decrypt, it is creating decrypted data but is not able to convert that data into the string. 在iPad端,当我尝试解密时,它正在创建解密的数据,但无法将该数据转换为字符串。 There is some problem coming in converting data into string using NSUTF8StringEncoding. 使用NSUTF8StringEncoding将数据转换为字符串时会出现一些问题。

Before sending from server to iPad we are converting it into base64 String. 从服务器发送到iPad之前,我们将其转换为base64 String。

The same XML file when encrypted and decrypted at iPad end works fine. 在iPad端加密和解密时,相同的XML文件可以正常工作。

I believe there are some special characters in the encrypted data coming from from server end ,therefore it is not decrypted at iPad end. 我相信来自服务器端的加密数据中会有一些特殊字符,因此在iPad端不会被解密。

Can anybody give me any suggestion on this. 有人可以给我任何建议吗?

Thank you! 谢谢!

You can not send encrypted string over the network. 您不能通过网络发送加密的字符串。 you need to convert encrypted NSString into Base64 String. 您需要将加密的NSString转换为Base64 String。 Then send this Base 64 string to ipad. 然后将此Base 64字符串发送到ipad。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM