Secure delete with python
Benjamin Niemann
b.niemann at betternet.de
Mon Sep 6 09:25:51 EDT 2004
Boris Genc wrote:
> Hi everybody.
> I was wandering is there a method or a function already implemented in
> python that supports secure deletion of data?
>
> I'm interested in something which is able to securely wipe data (from
> single file to bunch of MB's), and that should run both on Linux and
> Windows.
>
> I tried on google, but I hadn't found anything useful to me.
>
> Thank you very much in advance.
>
> Boris Genc
something like
fp = open(path, "wb")
for i in range(os.path.getsize(path)):
fp.write("*")
fp.close()
os.unlink(path)
is probably all you can do in a portable way (multiple write phases with
different data could improve the 'security'). But a problem that cannot be
solved in a portable way is that the data might exist at other locations on the
disk (e.g. temporary file, backup, swapfile...). Unless you know *exactly* that
there *cannot* be another copy of the data, you would have to erase all unused
parts of the filesystem, too - a process that heavily depends on which
filesystem is used.
More information about the Python-list
mailing list