- $fs = filesize ($fp_src);
- if ($fs === false || $fs == 0 || !extension_loaded('mcrypt'))
- return false;
-
- /* Init module */
- $m = mcrypt_module_open('rijndael-256', '', 'ofb', '');
- /* Extract key and iv. */
- $crypt_key = $k;
- $md5_key = md5($crypt_key);
- $iv = jirafeau_crypt_create_iv ($md5_key, mcrypt_enc_get_iv_size($m));
- /* Decrypt file. */
- $r = fopen ($fp_src, 'r');
- $w = fopen ($fp_dst, 'c');
- while (!feof ($r))
- {
- $dec = mdecrypt_generic($m, fread ($r, 1024));
- if (fwrite ($w, $dec) === false)
- return false;
+ $b = '';
+ foreach (str_split($hex, 2) as $pair) {
+ $b .= chr(hexdec($pair));