Shredding files in .NET

2019-01-15 03:10发布

问题:

Is there a SDK that can be used in managed code to shred files securely?

EDIT: This is the only link i could find in google that helps me

EDIT: Either SDK or some kind of COM based component.

回答1:

This code from codeproject may be a good starting point.

Eraser has been around for years, you could call out to it by using System.Diagnostics.Process, or at least review the algorithm there.



回答2:

Technology has changed in the past few years so when I happened to see this answer (why wasn't an answer accepted again?) I wanted to provide an update for others with similar questions.

Please note that shredding is very much filesystem and media dependent. Attempting to "shred" a file on a log based filesystem or a filesystem stored on smart (write leveling) flash isn't going to get you very far. You would have to, at a minimum, write enough data to complete fill the device to hope that the old data might be overwritten one time.

More likely you would have to write several smaller files and when you get FS full, delete one and then keep writing a new one, to ensure that all reserved space has been overwritten as well. Then you will probably be fairly safe. Probably.

I say probably because the storage media/FS could decide that a block was failing (or used too much relatively) and map it away substituting some other part of the disk instead. This is a per-block thing of course, so any much larger file is unlikely to be reconstructed.



回答3:

Take a look at Windows.WinAny.Helper at the CodePlex. It has SecureDelete extension which allows you to shredd files with different algorithms like Gutmann, DoD-7, DoD-3, Random or Quick.