+ File Decryption
This commit is contained in:
@@ -9,21 +9,28 @@ require("./lib.php");
|
||||
* as low as possible.
|
||||
*/
|
||||
|
||||
define("INPUT_FILE", "./test_input_file.txt");
|
||||
define("OUTPUT_FILE", "./example.enc.php");
|
||||
define("DEC_OUTPUT_FILE", "./example.dec.php");
|
||||
define("INPUT_FILE", "./lib.php");
|
||||
define("OUTPUT_FILE", "./testdir/" . "./example.enc.php");
|
||||
define("DEC_OUTPUT_FILE", "./testdir/" . "./example.dec.php");
|
||||
|
||||
// Make sure the testing folder exists
|
||||
if ( !file_exists("./testdir") ) {
|
||||
mkdir("./testdir", 0777, true);
|
||||
}
|
||||
|
||||
|
||||
// Initialize the class
|
||||
$lib = new kpcrypt();
|
||||
|
||||
// $lib->setEncryptionBlocks(128); // This will take ~10 times more time, but will use half as much memory.
|
||||
// Really the best value is the default one.
|
||||
|
||||
$enc_start = round(microtime(true) * 1000);
|
||||
|
||||
// Encrypt the file
|
||||
$lib->encryptFile(INPUT_FILE, OUTPUT_FILE);
|
||||
|
||||
$enc_end = round(microtime(true) * 1000) - $enc_start;
|
||||
|
||||
$dec_start = round(microtime(true) * 1000);
|
||||
|
||||
// Decrypt the file as well
|
||||
@@ -36,15 +43,14 @@ $dec_end = round(microtime(true) * 1000) - $dec_start;
|
||||
*/
|
||||
|
||||
echo "\n\n";
|
||||
echo "Input File Size: " . filesize(INPUT_FILE) / 1024 / 1024 . "Mb";
|
||||
echo "Input File Size: " . round(filesize(INPUT_FILE) / 1024 / 1024, 2) . "Mb";
|
||||
echo "\n";
|
||||
echo "Output File Size: " . filesize(OUTPUT_FILE) / 1024 / 1024 . "Mb";
|
||||
echo "Output File Size: " . round(filesize(OUTPUT_FILE) / 1024 / 1024, 2) . "Mb";
|
||||
echo "\n";
|
||||
echo "Peak Memory: " . memory_get_peak_usage() / 1024 / 1024 . "Mb"; // Check the memory in kb
|
||||
echo "\n";
|
||||
echo "Encryption Time: $enc_end ms\n"; // 9700k = ~210ms
|
||||
echo "Peak Memory: " . memory_get_peak_usage() / 1024 / 1024 . "Mb"; // Check the memory in Mb
|
||||
echo "\n";
|
||||
echo "Encryption Time: $enc_end ms\n"; // 9700k = ~210ms ( 4Mb = 100ms )
|
||||
echo "Decryption Time: $dec_end ms\n";
|
||||
echo "\n\n";
|
||||
echo "\n";
|
||||
$errors = $lib->getErrors();
|
||||
echo "Errors: " . ( !empty($errors) ? "\n" . json_encode($errors, JSON_PRETTY_PRINT) : "No Errors!");
|
||||
|
||||
Reference in New Issue
Block a user