You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

34 lines
591 B

package Encryption
import (
"os"
)
func SecureDelete(FilePath string) error {
var (
file *os.File
fileInfo os.FileInfo
size int64
zeroBytes []byte
e error
)
file, _ = os.OpenFile(FilePath, os.O_RDWR, 0666)
defer file.Close()
// Find out how large is the target file
fileInfo, e = file.Stat()
if e != nil {
return e
}
size = fileInfo.Size()
// Create byte array filled with zero's
zeroBytes = make([]byte, size)
_, e = file.Write([]byte(zeroBytes))
if e != nil {
return e
}
e = os.Remove(FilePath)
if e != nil {
return e
}
return nil
}