用 python 或者 ruby​​ 编写文件粉碎机?

发布于 2024-08-31 03:30:47 字数 102 浏览 12 评论 0原文

在学习 python 和/或 ruby​​ 的过程中,我想知道如何实现文件粉碎机?我希望它接受一个文件作为参数,然后采用一种算法使该文件不可恢复。稍后可能会添加对多个文件甚至整个目录的支持。

In the effort to learn python and/or ruby, I was wondering how a file shredder would be implemented? I would like it to take in a file as an argument and then employ an algorithm to make that file unrecoverable. Would possibly add the support for multiple files or even whole directories later.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

世态炎凉 2024-09-07 03:30:47

警告一下,由于日志、写时复制文件系统、磨损均衡(闪存)以及现代系统中使用的其他技术,碎纸机通常会在现代系统上取得不同程度的成功。可能想查看维基百科了解一些陷阱。


简而言之,您需要能够直接在当前现有数据之上写入。有几种不同安全级别的不同模式,但通常如果您使用随机数据(四舍五入到下一个块大小)覆盖文件大约 25 次,文件应该完全不可恢复(至少是数据的副本)。还有其他技术可以在更少的传递中安全地覆盖它(3 遍、随机、1、然后 0 也可以很好地工作)。

Just as a warning, shredders generally will have varying levels of success on modern systems, thanks to journals, copy-on-write file systems, wear leveling (flash), and other techniques used in modern system. Might wanna check out wikipedia on some of the pitfalls.


In short, you'd need to be able to write directly on top of the currently existing data. There's a few different patterns of varying levels of security, but often if you overwrite the file about 25 times with random data (rounding up to the next block size) the file should be completely unrecoverable (at least that copy of the data). There are other techniques that can securely overwrite it in less passes (3 passes, random, ones, then zeros also works decently well).

童话 2024-09-07 03:30:47

因为这是一次学习练习,而不是保护数据的专业尝试。这个怎么样:
1. 发现文件的长度。
2. 将 0 写入文件的相同长度。
3. 保存文件。
4. 删除文件。

然后创建另一个程序来尝试恢复该文件。

但是,是的,如果想要做一些专业的事情而不仅仅是练习,请看看 kitsune 的答案。

Since this is a learning exercise and not a professional attempt to secure data. How about this:
1. Discover the length of the file.
2. Write 0's to the same length of the file.
3. Save the file.
4. Delete the file.

Then make another program that tries to recover the file.

But yes, if looking to make something professional and not just an exercise, look into kitsune's answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文