Encrypt nsdata in iphone and decrypt it in php

I am new to Iphone development, I want to create an application in which I need to upload some data to a php server using my Iphone application. To do this, I have a file on Iphone, the contents of which I must upload to the php server. To do this, I converted the contents of the file to NSData, and now I want to encrypt this nsdata object, and then transfer it to the php server and on the php server, firstly, I need to decrypt the nsdata object, after which I have to upload it to the server .

But I cannot find a way by which I can encrypt some data in an Iphone application and then decrypt it in php.

And also I want to compress the encrypted data before transferring it to php, and then unpack this data to php.

The full flow of my application

           IPhone

NSData → Encrypted NsData → Compressed Encrypted Data

           php

Compressed encrypted data → uncompressed encrypted data → decrypted (original) NSData.

Can someone help me how can I develop such an application?

Thanks in advance.

Gaurav

+3
source share
3 answers

I wrote an article about this on my blog: http://www.em-motion.mobi/?p=139

+3
source

The best way is probably to encrypt NSData using a public key cryptosystem, distributing the public key with the application, encryption, then only your PHP application can decrypt using the private key.

PHP OpenSSL public/private key.

$key = openssl_pkey_get_private('file:///path/to/my/secure/privatekey', $my_secure_passphrase);
openssl_private_decrypt($nsdata, $decrypted_data, $key);

openssl_private_decrypt() , NSData , . , iPhone , , .

0

, AES CommonCrypto.

NSData, . , , "" " (IV)".

, .

, openssl , . - :

"Salted__", 8 .

, .

0
source

Source: https://habr.com/ru/post/1733643/


All Articles