如何加密iOS中的mp3文件 [英] How to Encrypt mp3 Files in iOS
问题描述
当播放文件时,我加载转换成AVPlayerItem,如下所示:
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];
我想继续将该项目加载到AVPlayer并播放。
所以我的主要问题是:我们如何在这些mp3文件存储在磁盘上时加密,以确保他们不能被任何拥有越狱设备的人从文件系统中拔出? / p>
我已经看过Stack Overflow,但找不到有用的东西。
希望有人可以帮助我出来谢谢
查看 NSData 中的-encrypt-nsdata-with-private-key-and-decrypt-with-public-key>此线程。
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
Check out this thread on adding RSA encryption/decryption to NSData
.
这篇关于如何加密iOS中的mp3文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!