Secure delete with python
Ville Vainio
ville at spammers.com
Mon Sep 6 16:11:03 EDT 2004
>>>>> "Benjamin" == Benjamin Niemann <b.niemann at betternet.de> writes:
>> fp = open(path, "wb")
>> for i in range(os.path.getsize(path)):
>> fp.write("*")
>> fp.close()
>> os.unlink(path)
Benjamin> and there is no guarantee that this actually overwrites
Benjamin> the old file. The filesystem may choose to write the new
Benjamin> content at another location of the disk, leaving the
Benjamin> original data untouched.
Seriously? What OSen are known for doing this? I'd had thought that if
the file size is unchanged, the data is always written over the old
data...
Also, when overwriting a file, it's better to do it several times,
with alternating bit patterns and "syncing" the disk after each
pass. Of course even that is not going to guarantee anything because
it may just go to the hardware cache in the disk unit, but it's
reasonable if you are overwriting lots of data at once.
Performing these steps, you'll at least get a good false sense of
security ;-).
--
Ville Vainio http://tinyurl.com/2prnb
More information about the Python-list
mailing list