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

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

问题描述

我有一个应用程序从我们的Web服务器下载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文件存储在磁盘上时加密,以确保他们不能被任何拥有越狱设备的人从文件系统中拔出? / 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屋!

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