We help IT Professionals succeed at work.

Permanently Deleting Files Code Modification Help Needed

ST3VO
ST3VO asked
on
208 Views
Last Modified: 2013-11-05
Hi all,

Whiles browsing around EE I found the following code with is supposed to delete a file without the posibility of being recovered!

Here is the code I found:

function KillFile(FileName:string):boolean;
var
   f:file;
   Buf:array [0..1023] of byte;
   i:integer;
begin
 for i:=0 to SizeOf(Buf)-1 do
  Buf[i]:=0;

try
 AssignFile(f,FileName);
  FileMode:=2;   // Read and write access
  Reset(f);
  while not eof(f) do
    BlockWrite(f,Buf,SizeOf(Buf));
  CloseFile(f);
  Erase(f);
 except
 on e:exception do
 begin
   Result:=false;
   exit;
 end; // except
end; // try
Result:=true; // File successfully deleted
end;


Example: KillFile('c:\myfile.txt');


Now, after reading a bit more on the topic you need to delete the file more than 50 times for it not being recoverable....that's what I read anyway!

So, is this function not completely secure then?  and if not...How can I COMPLETELY erase files without the possibility of recovery please?

Thanks

ST3VO
Comment
Watch Question

Top Expert 2007

Commented:
Recovered by whom?  ;)

Overwriting the file with random data 1 or 2 times (probably better than just zeros, but I'm not an expert)  should be ok in ninety plus percent of cases. For the file to not be recoverable by a forensic expert with the best equipment and lots and lots of time, then yes, 50x is probably a good bet. That's what all erasing utilities do, as far as I know - overwriting the data a specified number of times. There's not much more you can do, except for physically destroying the harddisk. No function can do more than to overwrite...
But I'm sure other people here know more about this subject :)

Author

Commented:
Ref: Recovered by whom?

If I sell my PC, I have personal files! Nothing illegal...Just Personal! Which I want to erase properly!

Also, I am very curious of how it could be done :o)

Commented:
First, I am just responding to follow this thread, but to provide a comment, if you look at an erase function logically one that writes each byte of the file where it resides on the disc drive with a zero, even one time, how could anyone recover the data.

Take an ASCII file, with the text "little red riding hood" and you write each byte with a zero, your file would be '0000000000000000000000".

It "seems" as though nothing would be needed.

I am truly curious to read what others may say on this subject. A program called eraser.exe will write over a file with different sorts of data and any number of times. But once "should be enough!(?)

John
Social distance; Wear a mask; Don't touch your face; Wash your hands for 20 seconds
CERTIFIED EXPERT
Top Expert 2014
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Lukasz Zielinskisoftware developer
CERTIFIED EXPERT
Top Expert 2008

Commented:
by us goverment standard file shredder should pass 7 times over file, very popular method is Gutmann algorithm: http://en.wikipedia.org/wiki/Gutmann_method

ziolko.
aikimarkSocial distance; Wear a mask; Don't touch your face; Wash your hands for 20 seconds
CERTIFIED EXPERT
Top Expert 2014

Commented:
There are different regulations, industry, state and federal, that determine the number of passes and type of overwriting data patterns:
http://www.lc-tech.com/software/filex-definitions.html

" Health Insurance Portability and Accountability Act (HIPAA)
www.cms.hhs.gov/hipaa
" Gramm-Leach-Bliley Act
www.ftc.gov/privacy/privacyinitiatives/glbact
" Sarbanes-Oxley Act
www.aicpa.org/info/sarbanes_oxley_
summary.htm
" Identity Theft and Assumption Deterrence Act
www.ftc.gov/os/statutes/itada/itadact.htm
" Childrens Online Privacy Protection Act
www.ftc.gov/ogc/coppa1.htm

If you are donating or selling your PC, you aren't subject to the same regulations.

If your hard drive contains Top Secret data, you must degauss it.  Wiping is not enough.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.