DEV Community

Cover image for Remove-forever: My first deno module & data erasure explanation

Posted on

Remove-forever: My first deno module & data erasure explanation

In order to get into deno, I made my first module and it was a real joy.
But let me tell you what it's for.

Your data is not secure when it is deleted

Under normal circumstances, when your OS or a program deletes a file for good (deleted from the recycle bin for Windows), the pointer that used to locate your file on the hard drive is erased and the file is no longer there.
But it's only on the surface because the data is still there!

Indeed, if one really had to "erase" each file it would take a considerable amount of time and that's why deleting a file works like that.

But then, what's the purpose of this module?

Security and privacy. It's not uncommon to have confidential or embarrassing data that one would like to be deleted forever.

Governments use such processes, even going so far as to physically destroy drives. But let's be serious, nobody here needs to go that far 😄

A use that will speak to more people is probably the following: if you sell a PC or a hard disk maybe, it can be interesting to erase all traces and pictures.

What's the concept?

file deletion

Permanent data erasure goes beyond basic file deletion commands, which:

  • Allow for selection of a specific standard, based on unique needs,
  • Verify the overwriting method has been successful and removed data across the entire device.

The basic principle is to write files before deletion in order to make recovery harder. With remove-forever, you get to choose the standard that follow your needs. Each one is composed of instructions about how many passes it should perform.

It goes from a simple pass of zeros to a 35 passes algorithm. Remove-forever comes with its own algorithm to ensure your data is safe:

  • A pass of cryptographically strong pseudo-random data,
  • The file is then renamed,
  • Truncated to hide the file size.
  • And finally files timestamps are randomized.

Remove-forever is composed of two parts: a deno module with a straightforward API and a command line interface optimized to delete files on the fly.

  • Choose your standard
  • Create your own standard
    • on files
    • on directories
  • Wipe disk (TODO)

🚀 Quick Start

If you want your application to delete specific files with a pass of cryptographically strong pseudo-random data, use one of these code snippets:

import remove from "";

await remove("./trash")
await remove("./vault/secret.txt")
Enter fullscreen mode Exit fullscreen mode
import { remove, fileStandards, directoryStandards } from "./mod.ts";

const count = await remove("./trash/secret.txt", {
  fileStandard: fileStandards.gutmann.remove,
  directoryStandard: directoryStandards.unsafe.remove,
  ignoreErrors: true,

console.log(`Removed ${count} files and folders!`)
Enter fullscreen mode Exit fullscreen mode

What about the command line tool?

It's very simple to install and use.

deno install --allow-write --allow-read --unstable -n remove
Enter fullscreen mode Exit fullscreen mode

Note: Due to the use of Deno.utime and the confirmation request in the CLI, you will need to use the --unstable flag.

CLI demo

CLI help

I'd be very grateful for your remarks. This project is very young and it is also my first post.

Top comments (0)