I am searching for a software that would encrypt data and then delete it (as opposed to just deleting or wiping).

With that, even if the file is recovered, you still have to break the encryption to get the data.

I suppose manually I could encrypt the files through GPG and then delete them but I was wondering if there a more automated option through specialized software.

  • 15
    Why not just overwrite the file with random data, e.g., using shred? What do you hope to gain by encrypting the file? The only benefit I can see is that if you change your mind and decide to recover the file, it's possible as long as you have the enryption key (but you didn't specify this in your question, so I can't be sure that you want this capability). – apsillers Sep 17 '12 at 13:49
  • 5
    Even if you do this. The previous copy would not be encrypted and theory could be recovered. A hdd will often move a file or be in seperate sectors if its fragmented. If you want to do this right, start with the file being encrypted, never have a file that isn't encrypted. – Ramhound Sep 17 '12 at 14:00
  • 2
    The crux of the issue is it should be encrypted before it gets deleted. "Way before" as in at moment of first opportunity and well before it gets stored to disk. – bmike Sep 17 '12 at 17:04

I understand why you are asking and you are kinda on the right track. You think that if you encrypt the data before shredding it that if someone was able to reconstruct the data all they would get is encrypted data. It's a good thought, however when you encrypt a file it makes an encrypted copy of the file on another part of the file system. The original still has to be shredded anyway, either manually or automatically by the utility. So by encrypting it then shredding the encrypted file you're actually leaving 2 copies of the file rather than one, causing a net decrease in security.


I am sorry, but this approach does not work because the encrypted files are likely stored at another location on your hard drive.

For the same reason shred does not work reliably anymore either. The decision where to store data on a hard drive is made by the controller on the device. The operating system may give a hint, but the controller will find a suitable location.

On solid state disks the number of writes to each location is limited, so the controllers are very sophisticated and spreading writes around. But even on old style disks the controllers try to avoid possible bad sectors.

Possible Solutions

  • Use full disc encryption. This way plain information is never written to the medium.
  • If that is too late, wipe the complete disk.
  • And of course there is the low tech solution: Physically destroy the medium
  • 1
    Along the "wipe the complete disk" track - Darin's Boot And Nuke (dban.org) is a good tool for this task, at least for non-SSD drives (I haven't looked into it for SSDs), as part of its erasure is various methods of writing over the sectors on the drive. – Shauna Sep 17 '12 at 14:37
  • There are tools (like eraser), that can wipe all unused disk space (fill it up until it's full), this could be an alternative to wipe the whole disk. – martinstoeckli Sep 17 '12 at 19:03
  • Full disk encryption FTW. All of the OP's troubles would be negated by this fact. That is, assuming that encryption will not be compromised. – NickSuperb Sep 19 '12 at 6:25

Your concept is a good one, but there's actually a more efficient method called file shredding. Instead of just marking the sectors as free, shredders first overwrite those sectors with data. This data may be a sequence of zeros, or random values. The goal is to prevent recovery by making the data on the disk unreadable.

On Linux, you can use shred:

shred -u <file_name>

By default, this overwrites the sectors 3 times. You can alter this count using the -n switch:

shred -n <count> -u <file_name>

However, even a single pass will do the job for software-based recovery.

If you're worried about attackers with a lot of patience and a lot of money, you might want to take a look at data recovery techniques that can retrieve data even after it's been overwritten on the disk. More complex analysis, such as magnetic force microscopy, might be able to recover data that has since been overwritten. However, a large number of experts (including the NSA) consider this to be near impossible with modern drives.

Despite this, there are standards that attempt to make analysis of the disk surface more difficult. These aim to apply certain bit patterns such that any latent information is degraded beyond recovery. These patterns are designed based on the physical construction of magnetic disks. For example, the pattern "0xF6, 0x00, 0xFF, random, 0x00, 0xFF, random" (i.e. one whole pass of each) is designed to eliminate data traces from standard magnetic platters. Alternative methods use different types of patterns for different devices, with some using dozens of passes. However, this is mainly thought to be unnecessary, even for classified data.

Further reading:

  • 4
    I always wondered: if you really need this kind of certainty, isn't it many times easier/cheaper/safer to just physically obliterate the disk? Physically shred it to near-dust and then melt it down. The price of the disk surely can't be an issue at this level. – Joachim Sauer Sep 17 '12 at 10:32
  • 2
    @JoachimSauer It's only recently (in the last 5-10 years or so) become cheap enough to do that. Magnetic degaussing isn't flawless or cheap, and physical disk shredders are very expensive to buy and run too. But you're right, the current "optimal" method is indeed to buy a new disk and destroy the old one. – Polynomial Sep 17 '12 at 10:45
  • 3
    @Izkata: hammering, electromagnetic damage, and fire isn't a reliable way to destroy data, with appropriate tools and skills it is still possible to recover a fairly large amount of data from the remnants. You need to either melt or chop the disk into dusts if you really want to make sure noone can recover anything. – Lie Ryan Sep 17 '12 at 18:12
  • 1
    @LieRyan I'm a little skeptical that hammering a disk (the actual platters) into pieces and then burning it isn't good enough. Recovering data under those circumstances would be impossible, or at least as improbable as brute-forcing a strong encryption algorithm in a short period of time. Unless you can provide examples where someone has actually done this successfully. – Phil Sep 17 '12 at 20:44
  • 1
    Agreed. Unless you're literally planning the next 9/11, nobody is going to spend the time or money analysing your old disks. Take a hammer to it until you hear the platters smash. If you're super-paranoid, do a single-pass wipe of random data over the disk beforehand. – Polynomial Sep 18 '12 at 5:52

In a Linux shell this would look like:

shred -u your_file.xxx
  • 1
    TIL there’s a loaded, unsecured shotgun in the trunk of every Linux. – Konrad Rudolph Sep 17 '12 at 12:32
  • 2
    @KonradRudolph, it's been there forever. It's called dd. – gowenfawr Sep 17 '12 at 14:05
  • @gowenfawr True, hadn’t thought of that even though I’ve used dd previously to shred files. :) – Konrad Rudolph Sep 17 '12 at 14:08
  • 4
    Then there was a time I needed to format a floppy disk and my Sparc IPX didn't have a 3.5" drive, but my officemate's did... since she was in a meeting I just popped it in and ssh'ed over to run 'fdformat /dev/sda'. After it had run for a minute without completion, I realized that I typed sda (SCSI disk) instead of fda (Floppy disk) by mistake... I had friends guard the door while I reinstalled SunOS on her system. – gowenfawr Sep 17 '12 at 14:39

Yes, you can use a file shredder rather than encrypting it. That's a better solution.

  • How do you figure? If the file was encrypted from the start, then marking the file to be deleted is enough, because the only data on the hdd is random. – Ramhound Oct 5 '12 at 13:20
  • 1
    It's faster and built for it, what do you want more? – Lucas Kauffman Oct 5 '12 at 13:36

As many before me have stated, I think you need to re-think your solution. However, I could recommend to encrypt it with TrueCrypt, when doing so - you can choose to do a wipe of the existing memory.

This will leave you with an encrypted harddrive, and no possibility of forensic methods recovering your old data. ALSO all your future data will be safe since they will be encrypted.

  1. Go to http://www.truecrypt.org/.
  2. Download their software, run it on your computer.
  3. Create a new encrypted space encompassing all of your hardrive, do not forget to choose to wipe existing data.

Good luck.


Of course the security of future data resides in your choice of cipher, password etc.

If you choose to Wipe with for example Gutmann 35 passes, it could take a long time.

  • I have recommended TrueCrypt because it can be used on multiple platforms, is decently easy to use and can solve the problem presented. – Gman Sep 18 '12 at 10:52

Zeroization (overwriting with zeros) is the standard preferred option for this.

Encryption is generally seen as something that can be decrypted eventually. You're correct that the residual data will still be on most operating systems after a delete operation is performed - for ease of use, most OSes will simply delete the reference to the file, leaving the data intact if one is smart enough to know how to recover it.

Since after a deletion it shouldn't matter whether or not the data is recoverable, the standard process is to overwrite the memory with all 0's, elminating the data entirely. That saves the CPU effort of encrypting the data, and eliminates the possibility that the attacker could find, or brute force, the encryption key.

  • 1
    simple zeroization is not sufficient if you really need to secure your data, through analysing the remnant magnetic pattern in the disks, it is possible to recover the data before the disk is zeroed. This process is expensive and complicated though, so for many people simple zeroization might be suffice. However, if you really need to secure your data without destroying the media, you need a shredder program that will overwrite the disk with a set of patterns designed to destroy this remnant patterns. – Lie Ryan Sep 17 '12 at 18:30
  • Fair enough, but I'd say that if your other thought was encryption for the purpose of deletion protection, zeroization will still up your game for pretty cheap. – bethlakshmi Sep 18 '12 at 12:49

File Murder seems to do what you are asking Though I am not sure how well since I have never used it myself and it may not support newer versions of Windows very well. You can find it here. I would also suggest that you search out information on the CMRR SAFE method of reliably erasing hard disk drives and solid state media. Good Luck.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.