PHP iOS AES加密 [英] PHP iOS AES Encryption

查看:104
本文介绍了PHP iOS AES加密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在麻烦尝试使用AES加密在PHP和我的iOS应用程序之间进行通信。

I've been having trouble trying to communicate between PHP and my iOS application using AES encryption.

到目前为止,我已经考虑过两种实现方法。第一个是使用OpenSSL。

在iOS端,我实现了一种模仿这里显示的代码的方式: http://saju.net.in/code/misc/openssl_aes.c.txt

So far, I've considered two methods of implementation. The first was to use OpenSSL.
On the iOS side, I implemented in a way to mimic the code shown here: http://saju.net.in/code/misc/openssl_aes.c.txt.

在PHP方面,我把生成的密钥和IV(来自iPhone)用作PHP openssl加密的输入。

On the PHP side, I took the generated key and IV (from the iPhone) and used it as input to the PHP openssl encrypt.

结果在输出方面有所不同

The results differed in terms of the output...

我还考虑过: http://iphonedevelopment.blogspot.com/2009/02/ strong-encryption-for-cocoa-cocoa-touch.html

但是这个帖子: iOS和PHP之间的AESCrypt解密阻止了我。

but this SO post: AESCrypt decryption between iOS and PHP deterred me.

项目是没有绑定到AES,它似乎是一个强大的加密算法,不会太难以实现。

The project is not tied down to AES, it just seemed like a strong encryption algorithm that wouldn't be too hard to implement.

我的基本问题是:实现可以轻松地用于iOS和PHP之间通信的良好加密算法的最简单方法是什么?

My basic question is: what is the easiest way to implement a good encryption algorithm that can easily be used to communicate between iOS and PHP?

推荐答案

正如在评论中所说,最简单的方法是使用HTTPS。

As said in the comments, it would probably easiest for you to use HTTPS.

一旦设置了一个iPhone应用程序,该应用程序必须通过HTTPS与PHP后端进行通信,并花费了很多时间尝试找出iPhone为什么不接受加密连接。

I once set up an iPhone app that had to communicate with a PHP backend over HTTPS, and spent many hours trying to find out why the iPhone wouldn't accept the encrypted connection.

事实证明,它没有工作,因为我在服务器端使用自签名证书。从证书颁发机构购买SSL证书解决了所有问题。

As it turned out, it didn't work because I was using a self-signed certificate on the server side. Buying an SSL certificate from a Certificate Authority solved all issues.

验证单个域名而无公司或扩展验证的SSL证书是非常便宜的,所以我建议您尝试一下!

SSL certificates that validate a single domain name without company or extended validation are really cheap, so I suggest you give that a try!

这篇关于PHP iOS AES加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆