如何在iOS中加密mp3文件 [英] How to Encrypt mp3 Files in iOS

查看:159
本文介绍了如何在iOS中加密mp3文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序从我们的网络服务器下载MP3文件,并立即将它们存储在NSData对象中。然后将此对象写入存储到应用程序沙盒中/ Library / Cache文件夹中的.mp3文件。



当它是播放文件的时候,到一个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文件,而他们存储在磁盘上,以确保他们不能只是从任何人使用Jailbroken设备的文件系统中采摘? / p>

我已经看过Stack Overflow,但找不到任何帮助。



希望有人可以帮助我出去。感谢

解决方案

查看此线程添加RSA加密/解密到 NSData


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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆