How to Encrypt mp3 Files in iOS

拟墨画扇 提交于 2019-12-22 00:59:31

问题


I have an app that downloads MP3 files from our web server and momentarily stores them in an NSData object. This object is then written to a .mp3 file stored to the /Library/Cache folder in the app's sandbox.

When it is time to play the file, I load it into an AVPlayerItem like so:

    NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0]
                          stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.mp3", trackID]];

    NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];
    self.trackPlayerItem = [[AVPlayerItem alloc] initWithURL:fileURL];

I think proceed to load this item into an AVPlayer and play it.

So my main question is: How do I encrypt these mp3 files while they're stored on the disk to ensure they can't just be plucked from the file system by anyone with a Jailbroken device?

I've already looked on Stack Overflow but couldn't find anything that helped.

Hope someone can help me out. Thanks


回答1:


Check out this thread on adding RSA encryption/decryption to NSData.



来源:https://stackoverflow.com/questions/11764177/how-to-encrypt-mp3-files-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!