Perhaps itβs best to never save the file in decrypted state.
Rather, use stream filters to decrypt it on the fly and send it directly to the end user.
Update
Your option 1 is actually not that bad if you consider this code:
$filename = 'path/to/file'; $size = filesize($filename); $src = fopen('/dev/zero', 'rb'); $dest = fopen('/path/to/file', 'wb'); stream_copy_to_stream($src, $dest, $size); fclose($src); fclose($dest);
You can also choose /dev/urandom
, but that will be slow.
source share