webgeek
webgeek

Reputation: 23

flex encrypte local mp3

i'm building a MP3 service where an online file gets streamed from the internet and save in the local storage ( to prevent future data traffic ). Considdering this, i would like to encrypte the local file or don't make is usable outside my application. I managed to encrypte / decrypte the file but can't load a bytes array into a sound object. Also the decryption of a file takes about 5 seconds wich is too long.

I was thinking of making the MP3 corrupt and then rewrite the file again. Can somebody help me in this matter?

Thanks

Upvotes: 0

Views: 80

Answers (1)

Josh
Josh

Reputation: 8159

I had to do something similar for a VOD app I built last year. I ran into the same problems as you: client demanded the video be downloadable, but not be viewable anywhere but the app. DRM was out of the question for various reasons, so we decided to go with encryption. Our first schemes were too slow (5-10 seconds on an iPad 3) so we decided to destroy the file instead.

Basically, you need to look at the structure of your file format. For my format, the first 32 bytes were the header. We didn't want to destroy the header, because it is essential to the file and we did not want to risk corrupting it. So instead, we looked at the data after the header. We decided to disrupt every 16KB for byte 33 to like 1024KB or something (I won't say the exact range for obvious reasons).

Our disruption pattern was simple and easily reversible (needed if you want to play the file, obviously):

byte = MAX_BYTE_VALUE - byte;

That will basically flip values. So if MAX_BYTE_VALUE is 10 and byte is 3, it becomes 7. If it is 7, it becomes 3. There is no way it can fall out of range and no way the pattern could be broken. So we ran that on a small range of bytes at the beginning of the file, something like 60-100 bytes total, and our video file was still playable, but no sound existed anymore and the image was completely corrupted (large blocks of purple and pink with lots of static) as well.

Obviously, a DRM solution probably would have been better. But the client was adamant about not using DRM and insisted we use an encryption method instead. This method was effective and efficient, resulting in no dropped frames for my app while running. Hopefully that gives you an idea of how you could do this.

Upvotes: 1

Related Questions