0

I have been looking for a cost effective way to overwrite and remove a file in python (something like rm -P on macOS)

I have currently wrote something like

fileSize = os.path.getsize(filePath)
counter = 0 
  with open(filePath, 'w+') as file:
    while counter <= fileSize:
      file.write("0")
      counter+= 1

But come on.. .this is not good enough. I know in python we aren't able to get to a low level (ram) but I would like to implement something that is sufficiently better. I have heard that some people use srm to remove a file securely but that was back in 2013 and wondering if there is a better tool at this point.

If srm is still the lib to use, please send over an example on the best way to implement it.

Chris
  • 367
  • 4
  • 16

0 Answers0