Skip to content

Instantly share code, notes, and snippets.

@DeDu
Created March 17, 2014 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeDu/3804940cffc19db4aedf to your computer and use it in GitHub Desktop.
Save DeDu/3804940cffc19db4aedf to your computer and use it in GitHub Desktop.
<?php
// ... some code ...
$fileStream = fopen($file, "r");
$encFileStream = fopen($file . ".enc.data", "w");
$opts = [
'iv' => $iv,
'key' => $key,
'mode' => 'cbc'
];
fwrite($encFileStream, hex2bin('006D0300'));
fwrite($encFileStream, $iv);
stream_filter_append($encFileStream, 'mcrypt.rijndael-256', STREAM_FILTER_WRITE, $opts);
stream_copy_to_stream($fileStream, $encFileStream);
fclose($fileStream);
fclose($encFileStream);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment