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