fork download
  1. <?php
  2.  
  3. use Cryptography\Ciphers\Cipher;
  4. use Cryptography\Ciphers\Algorithms;
  5. use Cryptography\Ciphers\Modes;
  6. use Cryptography\Backends\DefaultBackend;
  7.  
  8. function decrypt_file($encrypted_file, $key, $iv) {
  9. $file = fopen($encrypted_file, 'rb');
  10. $ciphertext = fread($file, filesize($encrypted_file));
  11. fclose($file);
  12.  
  13. $cipher = new Cipher(new Algorithms\AES($key), new Modes\CFB8($iv), new DefaultBackend());
  14. $decryptor = $cipher->decryptor();
  15. $decrypted_text = $decryptor->update($ciphertext) . $decryptor->finalize();
  16.  
  17. $decrypted_file = fopen(substr($encrypted_file, 0, -4) . '_decrypted.txt', 'wb');
  18. fwrite($decrypted_file, $decrypted_text);
  19. fclose($decrypted_file);
  20.  
  21. // Print the decrypted content
  22. echo utf8_decode($decrypted_text);
  23. }
  24.  
  25. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  26. $key = $_POST['key']; // استلام المفتاح كمدخل من المستخدم
  27. $iv = hex2bin($_POST['iv']); // استلام iv كسلسلة سداسية وتحويلها إلى ثنائية
  28. $file_path = "Data.txt.enc";
  29. decrypt_file($file_path, $key,$iv);
  30. }
  31. ?>
  32.  
Success #stdin #stdout #stderr 0.02s 26148KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Notice:  Undefined index: REQUEST_METHOD in /home/90Wx1e/prog.php on line 25