如何安全地删除iOS中的文件? [英] How to securely erase a file in iOS?

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

问题描述

当我加密文件时,我想覆盖其内容,不仅删除它。我的目的是安全地删除文件。有没有办法在iOS中执行此操作?

When I encrypt a file I want to overwrite its contents, not only delete it. My intended purpose for this is to securely erase the file. Is there a way to do this in iOS?

推荐答案

打开映射的文件内存并覆盖数据,然后使用删除文件 NSFileManager

Open the file memory mapped and overwrite the data, then delete the file using NSFileManager:

NSFileHandle *file = [NSFileHandle fileHandleForUpdatingAtPath: filename];
[file writeData: data];
[file closeFile];

其中数据是NSData对象

Where data is an NSData object

这篇关于如何安全地删除iOS中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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