How to encrypt/decrypt uploaded image php/xcode - php

I've been using this code to upload an image : how to post an image to the web server
and it works fine.
My question is : is there a way to aes-256 encrypt the image with a passphrase before sending it and decrypting it with php on the server? It's like using these functions : AES Encryption for an NSString on the iPhone but instead of NSString, NSData.
Any help would be useful.

To my idea from iOS
you convert image to base64 string using this link
Now encrypt this string int AES264 using this link
On php side
Decrypt using this link
Decode base64 string using this link

http://highaltitudehacks.com/2013/09/26/ios-dev-encrypted-images-and-saving-them-in-app-sandbox/
this is how you achieve image encryption of images in iOS (one way at least) you can then simply post the result. but you have to find a way to exchange your encryption key. It would not be clever to simply send your keys within the same request... and if so you should at least use https

Related

what is the best way to Upload a file to a php webservice and save it to mysql database?

I'm creating a PHP web service that saves files to MySql database.
The client side of my application is Android.
What is the proper way to upload a file(image, pdf, etc.) from android and save it to MySql database using PHP?
I'm not looking for codes right now, just wondering how I can do that?
The android can use the base64 to encode the img. Then you create a post http request to your php server.Your php save the base64 code to the mysql.
When you read the img.You can decode base64 to img.
Note:If you encode a img to base64 the base64 code size will bigger then img.

Can server side PHP send encrypted data to client side?

I need to send images from server side to client side.
If I just echo the image data, it's not safe. In the client side, I need to process and use the images (I will use these images with web unity) but I don't want the original images to be exposed.
Any help is appreciated.
Will SSL do what you need?
If you need more (to prevent snooping), check out the http://php.net/manual/en/book.mcrypt.php library: you'll need to find a corresponding decryption function in Unity. Encypt the raw image data (e.g. jpeg or png) and send over the wire; decrypt in Unity and rebuild the image.

Encrypt Images in Android to send to a PHP server

What I have:
I have some images on SDcard, to be sent to a PHP server.
What I want:
I want to encrypt these images before sending to server. There will be a unique key, for every user of application, which will be used for encryption on Android Side and for decryption on PHP server side.
Please guide me how can I do this encryption and how should I send these encrypted Images to server. I can send simple images to a server (using multipart etc). But what should be the way to encrypt and then send the image to server?
I can write you some simple steps to achieve this:
Convert your image into bytes array. Read this
Convert that bytes array into Base64 string. Read this
Encrypt Base64 string using this sample code
Send the encrypted string to your server using ksoap or json
*If you reverse this process on server, you'll get your image back.
Tadaaa! :)

is there any other Base64 type encryption and decryption in php?

is there any other Base64 type encryption and decryption in php ?
The problem is that base 64 give a longer value and increases the size of the data whereas i'm looking for something to reduce the size of the data.
is there any ?
base64 is not an encryption but an encoding
pick an encryption algorithm from http://docs.php.net/mcrypt, see also http://docs.php.net/refs.crypto
to (possibly) reduce the size use a data compression algorithm, see also http://docs.php.net/refs.compression
Base64 isn't so much encrypting and encoding - anyone can return a base64 encoded file/string into the original.
If you want to reduce the data size, try compressing it using for instance http://php.net/zip. If you still need to send the the data to another system, you could then base64 encode the resulting compressed data.
Do you actually want to encrypt the content (a security measure) or just make it viable for transmission inside for instance an XML or JSON stream, or is compression your only concern?

Image uploading using another site's API - Bypassing my server

I want to use imgur's API to upload images however I don't want to use my server too much in the act because I'd like to keep bandwidth to a minimum.
The API accepts images in a base64 encoded string or binary.
Also if there's a way to encode images into base64 or binary in javascript that would be really useful to know too
JavaScript security restrictions prevent you from reading a local file and doing anything with it. That will be the reason that you cannot encode a file in Base64 and send it directly to that API.
Does Imgur have an API which accepts a direct file upload?

Categories