How should I start this project in Android? - android

Design/develop a simple prototype for file encryption. Prototype will upload image file from internal/external memory and will save in YoApp/test folder with encrypted file name (you don't need to encrypt file itself). For encryption you can use any simple and existing algorithm. Project will have single screen with upload button.

Related

Android: Decrypt and load a PDF without writing it on disk

I have some PDF files on the server, those files are encrypted using AES. Using an API call, I get the file-URL and the corresponding decryption key. Then I download the encrypted file. Now I need to decrypt the file using the key and need to show it in a PDF-renderer (i will use any pdf library, though I haven't decided the library yet). Now my question is, how can I decrypt the file without writing/saving the decrypted file to disk? The target is: the decrypted file should be only on RAM, so that no other cannot get the file without using the app. The risk is, if I write the decrypted file to disk, someone can connect the device to PC and can save the file. I want to decrypt it only on RAM and want to load/show the file from RAM. So that when anyone leaves the app, the decrypted file no longer exists.

Open an at runtime decrypted file with a third party application without storing the decrypted data

In my application I need to pass a dynamically decrypted file to a third-party application without saving it to the device.
Example: I have a self created encrypted file which contains both a pdf file and some requirements before the pdf file can be shown. If all requirements are true, that pdf file should be shown by a third-party PDF-reader.
So I need to start a new intent, but there is the problem. I have to give the URI of my pdf file, but I don't have a URI because I didn't save the file to the device.
Is there any way I can get this job done?
For very small PDFs, or PDFs encrypted with some sort of streaming encryption algorithm, you can create a pipe ContentProvider. Using a pipe, you basically pour data into an OutputStream, where the other side uses a Uri and ContentResolver to retrieve the corresponding InputStream.
However, the limits of heap space will severely constrain the size of the file, if you cannot process it in a streaming fashion (e.g., as you read the bytes in from HTTP, decrypt on the fly and pass the decrypted bytes to the OutputStream).
Here is a sample of creating such a ContentProvder.
Answer on my own question:
Together with the answer from CommensWare (and sample code) and this link I have found a semi-solution.
The sample code shows you how to make local files accessible for other applications with a content provider.
The second link describes the implementation of a delete method which deletes the file from the file structure even before it is completely opened by a third party application (and explains why this is possible).
So basically, after decryption, you create a file accessible from the content provider, open it with another application and delete it immediately.
For rooted phones this is still not a 100% solution because they could monitor local file structure changes and instantly copy the file after it has been created.

Where to put keystore file in Android?

I am currently working on a project that involves ssl communication. So, I want to copy my bks file to the device' s internal memory and access it afterwards. I am using a specific library for communication and I have to provide the bks file' s full path as a parameter to this library. Where should I put this bks file? Into the raw or assets folder or somewhere else? From which uri can I access this file? (In windows I am giving it C:\keys\blah.bks, so I have to give a similar uri like /data/data/com.example.exampleapplication/my_app/blah.bks or something like this.) How is this achieved in Android system?
Thanks in advance
Store it in the assets folder of your app.
but consider encrypting it and letting your program decrypt it, since files in the assets folder are user accessible

Android File encryption and decryption

My android application is configurable using an external XML file present in the SD Card. The changes in the configuration requires a new XML file to be copied in that location. This XML file needs to be encrypted. So if the user request a new config for the app, the steps would be:
New XML file is generated for desired configuration.
File is encrypted using some standard encryption utility.
The file is sent to client/user.
Client copies the file to SD Card, and starts my app.
My application opens the file, decrypt it, read the content and delete the file.
I need help in step 2 and 5. Which standard tool I can use to encrypt my XML file (Should use some standard encryption algo) and secondly how the file can be decrypted in my android app. I am looking into java crypto package.
You can use this:
Android encryption
Beware as you should salt your encryption key with something not stored on the app (coming from a server for example) so that by reverting the APK to code you couldn't read the file anyway.

Programmatically protect media files on sdcard of Android Phone

My application has to download some media files at runtime. I found that I can store them in internal storage so that only my application can access them.
The problem is that internal storage is limited. Now I want to store media files in sdcard but I want to protect them, so that users can not pull them out of the sdcard and distribute them illegally.
you can achieve this only by encrypt your downloading file with some key , so another application can not access your download file.If you want use that file in your application then you have to decrypt it .There is inbuilt encrypt and decrypt protocol available.(Cipher)
Note
But encrypt and decrypt has one disadvantage it will take time to decrypt file.

Categories

Resources