I'm working on a project to Encrypt files using AES encryption with a key generated from SHA-256 from a keyword.
My idea to claim this was to
first : read all bytes from a file
second : encrypt bytes
third : write encrypted bytes on same file
I had some reasons to write encrypted bytes on same file. one was to prevent data recovery. as far as I know, the standard way to do this is to write encrypted data on new file and then remove old file. but I know old file can still be recovered and thats the problem "If old non-encrypted data can be recovered, what is the use of encryption?"
In my experience, I could always reach last version of files when I recovered them, not the history of file changes.
for example I have text file with "This text" in it, and I change it to "This text is changed". When I recovered my files, I could just see a text file containing "This text is changed". (Can old version still be recovered ?!) . so this became my logic to rewrite encrypted data on same file which I'm sure its too risky and buggy !! but would this fulfill my wish ?
I've posted my codes and logics in stackoverflow here . Then answers made me search more about data recovery. I also could read this article about data recovery. If I'm not wrong, file systems on HHDs will just remove a pointer to the file not the file itself so it can be recovered. Thats where I thought I have to rewrite on same file but answers in stackOverFlow told me its useless.
So can you give me details how I can at least HELP preventing old and non-encrypted file from being recovered ?
Also same article wrote something about SSD hard drive, which I think might be my answer (I read if I rewrite data on SSD hard drives it might be completely unrecoverable). How would I do this ?
Thanks.
Any information about how can I overwrite the left space (in case I change my output and write encrypted files to elsewhere) and preventing data recovery could be helpful.
FYI: I code with JAVA... examples can help me too