如何安全删除文件?

Pau*_*ers 5 ruby secure-coding

有没有Gem或者在Ruby中安全地擦除文件的方法?我想避免系统中可能没有的外部程序.

通过"安全擦除",我指的是覆盖文件内容.

And*_*icz 3

如果您使用 *nix,一个很好的方法是使用 exec/open3/open4 调用 shred:

`shred -fxuz #{filename}`
Run Code Online (Sandbox Code Playgroud)

http://www.gnu.org/s/coreutils/manual/html_node/shred-inspiration.html

检查这个类似的帖子:

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

  • _“我想避免系统上可能不存在的外部程序。”_我认为这意味着人们无法假设使用什么操作系统,但希望在 Ruby 运行的任何地方运行。 (2认同)