by Craig Hillsdon (7 Submissions)
Category: Encryption
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Thu 21st September 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Secure delete, pass this procedure a filename with full path, and your file disappears for good.
Dim filenum As Integer, pos As Integer
Dim ByteArray() As Byte
Dim wipeout As String, newname As String
Dim mypath As String, myfile As String
'// redimension ByteArray
ReDim ByteArray(FileLen(filespec) - 1)
'// overwrite file 3 times with different wipeout characters
filenum = FreeFile
Open filespec For Binary As #filenum
For x = 1 To 3
'// set overwriting character
If x = 1 Then
wipeout = 35 '#
ElseIf x = 2 Then
wipeout = 88 'X
Else
wipeout = 32 'space
End If
'// create the overwriting ByteArray
For i = 0 To UBound(ByteArray)
ByteArray(i) = wipeout
Next i
'// overwrite original file with wipeout character
Put #filenum, 1, ByteArray()
Next x
Close #filenum
'// clear memory
ReDim ByteArray(0) As Byte
'// separate path from filename
myfile = filespec
Do
pos = InStr(myfile, "\")
myfile = Right(myfile, Len(myfile) - pos)
Loop Until pos = 0
mypath = Left(filespec, Len(filespec) - Len(myfile))
'// generate a random lowercase string that is the same length as the filename
newname = ""
For j = 1 To Len(myfile)
Randomize
newname = newname & Chr(Int(25 * Rnd) + 97)
Next j
'// rename file to new random name
'// this prevents the original filename from being recovered
Name filespec As mypath & newname
'// delete file which now contains no sensitive data
Kill mypath & newname
End Sub
No comments have been posted about Secure delete, pass this procedure a filename with full path, and your file disappears for good.. Why not be the first to post a comment about Secure delete, pass this procedure a filename with full path, and your file disappears for good..