2

I have a file shredder on my computer, and I wanted to know if it's possible to make one in JAVA just for learning sake. But, I'm not sure how exactly it works, so this is what I think it does, please correct me where I'm wrong.

So basically it keeps encrypting the bytes of the file, and then simply deletes it. But that seems too easy to me, so I must be missing something or be completely wrong. I've looked up how it works, but I always just get software advertisements.

Thanks for any response

Austin
  • 4,801
  • 6
  • 34
  • 54

4 Answers4

4

Please note that shredding is very much filesystem and media dependent. Attempting to "shred" a file on a log based filesystem or a filesystem stored on smart (write leveling) flash isn't going to get you very far. You would have to, at a minimum, write enough data to complete fill the device to hope that the old data might be overwritten one time. More likely you would have to write several smaller files and when you get FS full, delete one and then keep writing a new one, to ensure that all reserved space has been overwritten as well. Then you will probably be fairly safe. Probably.

I say probably because the storage media/FS could decide that a block was failing (or used too much relatively) and map it away substituting some other part of the disk instead. This is a per-block thing of course, so any much larger file is unlikely to be reconstructed.

Seth Robertson
  • 30,608
  • 7
  • 64
  • 57
1

At minimum, a software file shredder must write 0s into the physical media that used to hold the file.

Zian Choy
  • 2,846
  • 6
  • 33
  • 64
  • Possibly a stupid question, but would you want to rename the file to something random? – Austin Jun 05 '11 at 00:45
  • @Austin: It is possible depending on filesystem that renaming a file might cause the previous existence of a file by that name to be unknown, but some filesystems hash the file's name so that technique would not work. On the other hand, if you repeat using random words from a dictionary that includes the filename you previously chose you might be able to claim plausible deniability, though I have to say that it probably wouldn't protect you very much. – Seth Robertson Jun 05 '11 at 01:09
  • @Austin, that's not the same thing. When you delete a file, you just delete the file pointer and the data is still there, you just lose the pointer. Yeah, it depends on the FS implementation. You may implement or change your fs implementation to shred files on deletion but it comes with a huge cost. – ahmet alp balkan Jun 05 '11 at 22:58
1

Overwriting will solve the problem but it depends on the filesystem/platform (see the comment below). Here's a related question with .NET (not so much different than Java) Shredding files in .NET

ahmet alp balkan
  • 42,679
  • 38
  • 138
  • 214
0

What you can do is get the bites from the file one by one, set them to 0 and send them into oblivion aka trash :)

Stas Jaro
  • 4,747
  • 5
  • 31
  • 53
  • You do not need to read the bytes, and zero is not any more magic than 1. A better bet (IMHO) would be to set the bits to a random pattern if you were doing one pass since any intermediary level compression and particular nuances of storage technology (whether zero or one is the default state and whether it is easier to see if the bit had a previous value if it had a fixed value) would be irrelevant. – Seth Robertson Jun 05 '11 at 01:19