Securely Delete All Drive Data
If you actually need to securely wipe your non-SSD drive consider using
shred, or look at some
of the linked pages too.

Also I don't see much point in the pseudo-random data generation given
that you just want to make the previous content unrecoverable.  If you
a want faster program you could probably use a faster hash too.



For the code I only want to note that write might write less than the
specified number of bytes and that's not immediately an error.