import os;
use \Cryptography\Ciphers\Cipher;
use \Cryptography\Ciphers\Algorithms;
use \Cryptography\Ciphers\Modes;
use \Cryptography\Backends\DefaultBackend;
function decrypt_file($encrypted_file, $key, $iv) {
$file = fopen($encrypted_file, 'rb');
$cipher = new Cipher(new Algorithms\AES($key), new Modes\CFB8($iv), new DefaultBackend());
$decryptor = $cipher->decryptor();
$decrypted_text = $decryptor->update($ciphertext) . $decryptor->finalize();
$decrypted_file = fopen(substr($encrypted_file, 0, -4) . '_decrypted.txt', 'wb'); fwrite($decrypted_file, $decrypted_text);
// Print the decrypted content
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$key = b'*\x00\x00\x00\x00\x00\x00\x00*\x00\x00\x00\x00\x00\x00\x00'; // Should be 16, 24, or 32 bytes long
$iv = b'\xdam-4BW$\x89\x8b\x19\x9e0.G\x89\xcd'; // Should be 16 bytes long
$file_path = "Data.txt.enc";
decrypt_file($file_path, $key, $iv);
}
aW1wb3J0IG9zOwp1c2UgXENyeXB0b2dyYXBoeVxDaXBoZXJzXENpcGhlcjsKdXNlIFxDcnlwdG9ncmFwaHlcQ2lwaGVyc1xBbGdvcml0aG1zOwp1c2UgXENyeXB0b2dyYXBoeVxDaXBoZXJzXE1vZGVzOwp1c2UgXENyeXB0b2dyYXBoeVxCYWNrZW5kc1xEZWZhdWx0QmFja2VuZDsKCmZ1bmN0aW9uIGRlY3J5cHRfZmlsZSgkZW5jcnlwdGVkX2ZpbGUsICRrZXksICRpdikgewogICAgJGZpbGUgPSBmb3BlbigkZW5jcnlwdGVkX2ZpbGUsICdyYicpOwogICAgJGNpcGhlcnRleHQgPSBmcmVhZCgkZmlsZSwgZmlsZXNpemUoJGVuY3J5cHRlZF9maWxlKSk7CiAgICBmY2xvc2UoJGZpbGUpOwoKICAgICRjaXBoZXIgPSBuZXcgQ2lwaGVyKG5ldyBBbGdvcml0aG1zXEFFUygka2V5KSwgbmV3IE1vZGVzXENGQjgoJGl2KSwgbmV3IERlZmF1bHRCYWNrZW5kKCkpOwogICAgJGRlY3J5cHRvciA9ICRjaXBoZXItPmRlY3J5cHRvcigpOwogICAgJGRlY3J5cHRlZF90ZXh0ID0gJGRlY3J5cHRvci0+dXBkYXRlKCRjaXBoZXJ0ZXh0KSAuICRkZWNyeXB0b3ItPmZpbmFsaXplKCk7CgogICAgJGRlY3J5cHRlZF9maWxlID0gZm9wZW4oc3Vic3RyKCRlbmNyeXB0ZWRfZmlsZSwgMCwgLTQpIC4gJ19kZWNyeXB0ZWQudHh0JywgJ3diJyk7CiAgICBmd3JpdGUoJGRlY3J5cHRlZF9maWxlLCAkZGVjcnlwdGVkX3RleHQpOwogICAgZmNsb3NlKCRkZWNyeXB0ZWRfZmlsZSk7CgogICAgLy8gUHJpbnQgdGhlIGRlY3J5cHRlZCBjb250ZW50CiAgICBlY2hvIHV0ZjhfZGVjb2RlKCRkZWNyeXB0ZWRfdGV4dCk7Cn0KCmlmICgkX1NFUlZFUlsiUkVRVUVTVF9NRVRIT0QiXSA9PSAiUE9TVCIpIHsKICAgICRrZXkgPSBiJypceDAwXHgwMFx4MDBceDAwXHgwMFx4MDBceDAwKlx4MDBceDAwXHgwMFx4MDBceDAwXHgwMFx4MDAnOyAgLy8gU2hvdWxkIGJlIDE2LCAyNCwgb3IgMzIgYnl0ZXMgbG9uZwogICAgJGl2ID0gYidceGRhbS00QlckXHg4OVx4OGJceDE5XHg5ZTAuR1x4ODlceGNkJzsgLy8gU2hvdWxkIGJlIDE2IGJ5dGVzIGxvbmcKICAgICRmaWxlX3BhdGggPSAiRGF0YS50eHQuZW5jIjsKICAgIGRlY3J5cHRfZmlsZSgkZmlsZV9wYXRoLCAka2V5LCAkaXYpOwp9
import os;
use \Cryptography\Ciphers\Cipher;
use \Cryptography\Ciphers\Algorithms;
use \Cryptography\Ciphers\Modes;
use \Cryptography\Backends\DefaultBackend;
function decrypt_file($encrypted_file, $key, $iv) {
$file = fopen($encrypted_file, 'rb');
$ciphertext = fread($file, filesize($encrypted_file));
fclose($file);
$cipher = new Cipher(new Algorithms\AES($key), new Modes\CFB8($iv), new DefaultBackend());
$decryptor = $cipher->decryptor();
$decrypted_text = $decryptor->update($ciphertext) . $decryptor->finalize();
$decrypted_file = fopen(substr($encrypted_file, 0, -4) . '_decrypted.txt', 'wb');
fwrite($decrypted_file, $decrypted_text);
fclose($decrypted_file);
// Print the decrypted content
echo utf8_decode($decrypted_text);
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$key = b'*\x00\x00\x00\x00\x00\x00\x00*\x00\x00\x00\x00\x00\x00\x00'; // Should be 16, 24, or 32 bytes long
$iv = b'\xdam-4BW$\x89\x8b\x19\x9e0.G\x89\xcd'; // Should be 16 bytes long
$file_path = "Data.txt.enc";
decrypt_file($file_path, $key, $iv);
}