|
-
Jan 5th, 2002, 04:47 PM
#1
Secure Delete [Resolved by Alphanos]
Hi,
How can i securely delete a file in VB. I am writing an encryption utility and need to delete the source file securly after the encryption. By securly i mean, it can not be recovered easily. How can i achive that in vb.
Thanks for your help.
Danial
Last edited by Danial; Jan 6th, 2002 at 12:10 AM.
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Jan 5th, 2002, 05:04 PM
#2
Hyperactive Member
You can simply write overtop of the file several times. Open the file for binary, and write values of 0 overtop of all bytes in the file 2-3 times. Repeat with 255, then with 0 again, then delete the file. Besides the normal deletion, which removes the info about where it is, the original information in that location will be erased and not subject to testing for ghost bytes if you repeat the writing 2-3 times. It could still be recoverable by a very good expert if you just write with 0's, 255's, and 0's again; the repeats are important.
That's the most secure way I know of of deleting a file.
-
Jan 5th, 2002, 05:11 PM
#3
Thanks for responding
do you have any example code
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Jan 5th, 2002, 05:20 PM
#4
Hyperactive Member
IE.
VB Code:
Public Sub SecureDelete(ByRef FilePath As String)
Dim FileNum As Byte
Dim i As Long
Dim Value As Byte
FileNum = FreeFile
Open FilePath For Binary As #FileNum
Value = 0
i = 1
Do
If i = 3 Then Value = 255
If i = 5 Then Value = 0
Do Until EOF(FileNum)
Put #FileNum, , Value
Loop
i = i + 1
Loop Until i = 7
End Sub
Just wrote that here, so there might be a bug, test it out.
An alternative approach would be to write random bytes over top of the file a couple times, as that way there would be data and ghost data, but it would be impossible to recover the original anyway.
-
Jan 5th, 2002, 07:29 PM
#5
Originally posted by Alphanos
IE.
Just wrote that here, so there might be a bug, test it out.
An alternative approach would be to write random bytes over top of the file a couple times, as that way there would be data and ghost data, but it would be impossible to recover the original anyway.
Thanks for the code. It doesnt work though. The file size just keeps getting bigger and bigger and the loop doesnt end. Even one iteration takes ages.
Anyway thanks again really appriciated.
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Jan 5th, 2002, 09:37 PM
#6
Hyperactive Member
Oh, LOL !, I guess a line that I forgot might help .
VB Code:
Public Sub SecureDelete(ByRef FilePath As String)
Dim FileNum As Byte
Dim i As Long
Dim Value As Byte
FileNum = FreeFile
Open FilePath For Binary As #FileNum
Value = 0
i = 1
Do
If i = 3 Then Value = 255
If i = 5 Then Value = 0
[b]Put #FileNum, 1, Value[/B]
Do Until EOF(FileNum)
Put #FileNum, , Value
Loop
i = i + 1
Loop Until i = 7
End Sub
-
Jan 5th, 2002, 10:06 PM
#7
-
Jan 5th, 2002, 10:44 PM
#8
Hyperactive Member
LOL, my fault for writing faulty code and not checking it .
Lemme make a few changes here. Not quite sure what the problem was in the old one actually, but it can be fixed by using a slightly different approach.
VB Code:
Public Sub SecureDelete(ByRef FilePath As String)
Dim FileNum As Byte
Dim i As Long
Dim Value As Byte
Dim Position As Long
Dim FileLength As Long
FileNum = FreeFile
Open FilePath For Binary As #FileNum
FileLength = LOF(FileNum)
Do
If i = 2 Then Value = 255
If i = 4 Then Value = 0
Position = 1
Do Until Position > FileLength
Put #FileNum, Position, Value
Position = Position + 1
Loop
i = i + 1
Loop Until i = 6
End Sub
I'm about 99% sure that this one should work . (or at least have only some stupid syntax error that I missed)
-
Jan 5th, 2002, 10:55 PM
#9
-
Jan 6th, 2002, 12:06 AM
#10
Hyperactive Member
Hehe, sorry about that .
-
Jan 6th, 2002, 12:09 AM
#11
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Jan 6th, 2002, 12:25 AM
#12
Hyperactive Member
Oh yeah, one other thing: for simplification, you should probably add the kill to the end just before the end sub. That way you don't have to call it outside. As it is right now, it'll make it impossible to get the data that was there before back, but it doesn't actually get rid of the record of where the file is, so other files can't use the HD space. So just add
Kill FilePath
to the end of the sub.
-
Jan 6th, 2002, 12:28 AM
#13
Thanks i done that a while ago !! Thanks
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|