Delphi-Kylix
  Home arrow Delphi-Kylix arrow Secure File Deletion in Delphi
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

Secure File Deletion in Delphi
By: Jacques Noah
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 12
    2005-11-14

    Table of Contents:
  • Secure File Deletion in Delphi
  • Building the GUI
  • The code
  • The rest of the code

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Secure File Deletion in Delphi


    (Page 1 of 4 )

    Everybody knows that simply deleting a file from a hard disk doesn't truly make the file impossible to recover. Often, this is a good thing, but sometimes you want a file to be thoroughly deleted. Keep reading to find out how to accomplish this.
    A downloadable zip of the source code is available here.

    Introduction

    While cleaning my hard disk, I started to wonder what happens to files when they are deleted. We hear all the time that when we delete files, they do not really disappear and can be recovered. To understand what happens to the files, we need to know what happens when files are created. When a new file is created, Windows allocates a space or place on the hard disk that uniquely identifies this file. Windows does not really keep taps on what a file contains; the only things it knows about a file is where it is located, its size and perhaps its name.

    Now, when you delete a file (empty the recycling bin), all that happens is that Windows puts up a flag indicating that the space that used to belong to the deleted file is now available for re-allocation. At this point the file can still be recovered, but if you then create a new file or do anything that requires the OS to write something to the hard disk (such as restarting your computer), then the file will not be recoverable.

    So, to completely delete a file, Windows overwrites it over and over. The more it overwrites, the more difficult it becomes to recover a file, and thus the more secure the deletion of the file. The US department of Defense has created a standard (considered to be the safest) called ‘DOD 5220.22-M.' It encourages rewriting file contents up to 20 times to make it completely unrecoverable, even with the most sophisticated recovery software known today. What we will do in this tutorial is devise an algorithm that will do the following:

    • Open and overwrite the file contents.

    • Rename and delete the file.

    It’s fairly simple, but sufficient for anyone who wants to permanently delete their "secret" files. With this algorithm, even if someone manages to undo the renaming of the file or is able to undelete the file, the file would have been overwritten so many times that it will not be possible to recover its contents.

    What you need

    I’m using Delphi 7 Ent, but any version will do.

    More Delphi-Kylix Articles
    More By Jacques Noah


       · A good introduction to an increasingly important subject.The author mentions the...
       · The repeated rewriting of code here will simply erase the cache multiple times...
       · Presumably renaming the file is so it's name entry is overwritten in the directory,...
       · Hi, Please be aware that main code that does the DOD wiping is grossly...
       · The code does write over the original clusters. If you check the lcn,vcn and...
     

    DELPHI-KYLIX ARTICLES

    - Loading an XML Document into the DOM
    - Delphi Wrapper Classes and XML
    - Delphi and the DOM
    - Delphi and XML
    - Internet Access: Client Service
    - Finishing the Client for an Internet Access ...
    - The Client for an Internet Access Control Ap...
    - User Management for an Internet Access Contr...
    - Important Procedures for an Internet Access ...
    - Server Code for an Internet Access Control A...
    - Constructing the Interface for an Internet A...
    - Building a Server Application for an Interne...
    - Building an Internet Access Control Applicat...
    - Client Dataset: Working with Data Packets an...
    - Using the Client Dataset in an N-Tiered Appl...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek