Secure delete with python

Benjamin Niemann b.niemann at
Mon Sep 6 15:25:51 CEST 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)):

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