在我的应用程序中,我在 UIWebView 中显示 HTML 内容。 HTML 内容从服务器下载并存储在 iPad 的文件系统中以支持离线使用。 HTML 在其 CSS 文件中通过 @font-face 使用自定义字体:
@font-face {font-family: 'CustomFont'; src: url(Custom-Font.otf);}
为了完成这项工作,字体 .otf
文件也被下载并存储在 iPad 的文件系统中。
问题是,现在任何可以访问他的 iPad 文件系统的人都可以使用该字体(如果您使用 IExplorer 之类的东西,这真的很容易)。
这会导致一些法律问题,因为大多数字体提供商不允许免费分发他们的字体(当我使用此方法时,他们实际上是这样做的)。
我的问题:有什么方法可以让文件系统中的字体加密并在 UIWebView 尝试加载它们时解密它们?
最佳答案
参见 Protecting Data Using On-Disk Encryption在《iOS App 编程指南》中:
In iOS 4 and later, apps can use the data protection feature to add a level of security to their on-disk data. Data protection uses the built-in encryption hardware present on specific devices (such as the iPhone 3GS and iPhone 4) to store files in an encrypted format on disk. While the user’s device is locked, protected files are inaccessible even to the app that created them. The user must explicitly unlock the device (by entering the appropriate passcode) at least once before your app can access one of its protected files.
我没有对此进行测试,但我强烈认为无法使用 iExplorer 读取加密文件。
关于css - 保护 UIWebVIew 中的自定义字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11938858/