You can very difficultly obtain a true irrecoverable deletion of data. This is not related to algorithms but to physical properties of storage media.
You can only hope to reduce the risk (or opportunity) of themaking data being recoveredrecovery improbable. AndBut improbable is not impossible and the riskdifference between the two depends on the means that the potential recoverer has at its disposals and the value of the recovered information has.
A concrete example is hard drives: magnetic remanence creates a risk of undesired traces around the magnetic track. Writing random data several times reduces significantly the risk. HoweverWriting only 0 is for forensic experts like if you put a blank sheet of paper above printed page: it may be difficult to read, but with the right light you can start to guess the content. Moreover, very powerful people having atomic microscopes and plenty of patient and skilled staff at their disposal could still recover (at disproportionate costs) some data that you could no longer recover with ordinary reading heads ( using microscopic imagery of the surface combined with image analysis, two scientific fields that have made plenty of progress in the last years).
Another example are solid state disks, that. These usually try to avoid to physically overwritingoverwrite data,. SSD try to reduce reuse of storage elements. SSD because they are limited on the number of physical rewrites itthey can reliably deal with, so they. So drives are designed to perform logical rewrites elsewhere whenever possible, to increase their life time. You never really overwrite anything if you just overwrite a single file on an SSD. You can be sure of an overwrite only if you force the SD to reuse all available space, for example by overwriting the full SSD.
This being said, why trying to write such a program when there is already sdelete
. and similar products that were designed by experts in this field?