How would I go about playing a set of encrypted audio files in a audio player android app?
I have an app project where I would have a set of encrypted audio content stored on a users device. A single audio content (example: podcast) would in this case consist of multiple encrypted files. The app acts as a audio player, through which users listen to this audio content. For good user experience the whole content (podcast) should play seamlessly from one file to another. This works perfectly for normal audio files using android's MediaPlayer class.
For security measures, no decrypted file should at any point be present on the users device storage in a way that a user can access this file any other way than through my app (even on rooted devices).
The type of encryption to be used is not fixed yet, so I am open to any algorithm that would work best for this case.
I thought about decrypting each file before playing it. Files are a maximum of 25MB in size, and a AES encryption/decryption for such file takes some 300 milliseconds, so this does not disturb the user experience too much.
There are two problems I see here with two different approaches to decryption:
- If I decrypt a file and store it on device as a normal audio file, the user will be able to get to it (rooted devices) and use it outside my app.
- If I decrypt a file and keep it in system memory as lets say a byte array, how do I play this back to the user? I have found no way to do this using MediaPlayer, or have found any other library that would allow this out of the box. Maybe some audio streaming library could be modified to play out of a decrypted file stream?