Created
March 23, 2022 22:41
-
-
Save stephenwaite/4f9ec6ef88be25d1889869043ff2988f to your computer and use it in GitHub Desktop.
php de-crypto docs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$_GET['site'] = 'default'; | |
$ignoreAuth = true; | |
require_once __DIR__ . '/vendor/autoload.php'; | |
require_once("interface/globals.php"); | |
use OpenEMR\Common\Crypto\CryptoGen; | |
$crypto = new CryptoGen(); | |
$dir = new RecursiveDirectoryIterator(__DIR__ . "/sites/default/documents/", FilesystemIterator::SKIP_DOTS); | |
$subdirs = new RecursiveIteratorIterator($dir); | |
foreach($subdirs as $filename_path) { | |
$parent_dir = $subdirs->getSubPath(); | |
// echo $filename_path, PHP_EOL; | |
// documents are stored under numeric pid in documents folder | |
if (is_numeric($parent_dir)) { | |
$filename = basename($filename_path); | |
// echo $filename, PHP_EOL; | |
$new_name = $filename_path . "-decrypted"; | |
//echo $new_name; | |
if (!$fp = fopen($new_name, 'w')) { | |
echo "Cannot write file ($new_name)"; | |
exit; | |
} | |
$encrypted_file_contents = file_get_contents($filename_path); | |
//echo $encrypted_file_contents, PHP_EOL; | |
$file_contents = $crypto->decryptStandard($encrypted_file_contents, '', 'database'); | |
if (fwrite($fp, $file_contents) === FALSE) { | |
echo "Cannot write to file ($new_name)"; | |
exit; | |
} | |
echo "Success, wrote ($file_contents) to file ($new_name)"; | |
fclose($fp); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hello @jfischburg-lifemesh how put this code to? i was created new php but it not work. please tell me how to do with this code? thanks