| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
|
| 5 |
To dump the decrypted file using the given key on stdout, call: |
| 6 |
|
| 7 |
rijndael_decrypt_file( '../path/to/file.crypt' , 'mykey' ); |
| 8 |
|
| 9 |
Thus, here are the easy instructions: |
| 10 |
|
| 11 |
1) Add a line like the above into this PHP file (not inside these comments, but outside) |
| 12 |
e.g. |
| 13 |
rijndael_decrypt_file( '/home/myself/myfile.crypt' , 'MYKEY' ); |
| 14 |
|
| 15 |
2) Run this file (and make sure that includes/Rijndael.php is available, if you are moving this file around) |
| 16 |
e.g. |
| 17 |
php /home/myself/example-decrypt.php >output.sql.gz |
| 18 |
|
| 19 |
3) You may then want to gunzip the resulting file to have a standard SQL file. |
| 20 |
e.g. |
| 21 |
gunzip output.sql.gz |
| 22 |
|
| 23 |
*/ |
| 24 |
|
| 25 |
function rijndael_decrypt_file($file, $key) { |
| 26 |
|
| 27 |
require_once(dirname(__FILE__).'/includes/Rijndael.php'); |
| 28 |
|
| 29 |
$rijndael = new Crypt_Rijndael(); |
| 30 |
$rijndael->setKey($key); |
| 31 |
$in_handle = fopen($file,'r'); |
| 32 |
$ciphertext = ""; |
| 33 |
while (!feof ($in_handle)) { |
| 34 |
$ciphertext .= fread($in_handle, 16384); |
| 35 |
} |
| 36 |
fclose ($in_handle); |
| 37 |
print $rijndael->decrypt($ciphertext); |
| 38 |
|
| 39 |
} |
| 40 |
|
| 41 |
?> |
| 42 |
|