- /* Prepare module. */
- $m = mcrypt_module_open('rijndael-256', '', 'ofb', '');
- /* Generate key. */
- $crypt_key = jirafeau_gen_random (10);
- $md5_key = md5($crypt_key);
- $iv = jirafeau_crypt_create_iv ($md5_key, mcrypt_enc_get_iv_size($m));
- /* Init module. */
- mcrypt_generic_init($m, $md5_key, $iv);
- /* Crypt file. */
- $r = fopen ($fp_src, 'r');
- $w = fopen ($fp_dst, 'c');
- while (!feof ($r))
- {
- $enc = mcrypt_generic($m, fread ($r, 1024));
- if (fwrite ($w, $enc) === false)
- return '';