Securely overwriting a file?

Discussion in 'Mac Programming' started by rtl8187, Aug 7, 2010.

  1. rtl8187 macrumors newbie

    Joined:
    Aug 7, 2010
    #1
    I'm writing a desktop app where a temporary file
    needs to be securely erased as I want to be as
    responsible as possible with the users' data.

    I'd like to overwrite the file with 0s and 1s and
    then delete it.

    I don't know a lot about HFS+. Is there code out
    there that I can use that somebody can
    recommend?

    Thanks!
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    Just overwrite the file, then delete it. You can use any file-access functions that operate directly on files, such as the stdio functions: fopen(), fseek(), fwrite(), etc.

    Functions NOT to use would be ones like the NSData methods that write an NSData to a file. Those do NOT provide direct access to a file, and if the atomic option is used, don't even write to the same file.

    HFS has essentially nothing to do with it. Besides, you can't rely on the disk being HFS, so even if HFS were relevant, you can't count on it.
     
  3. zeppenwolf macrumors regular

    zeppenwolf

    Joined:
    Nov 17, 2009
    #3
    Get yourself some Style Points by using 0xDEADBEEF .

    ( Easy to tell if you've overwritten a sector, too... )
     

Share This Page