asdas - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of asdas.php

  1. <?php
  2.  
  3. $plaintext = 'O:8:"userdata":3:{s:4:"role";s:4:"user";s:2:"id";i:70;s:3:"uid";i:72;}';
  4. $key = "8b362e210615e66b3bf7f69f6c819056";
  5. $cipher = "aes-256-ctr";
  6. $iv = "ABCDEFGHIJKLMNOP";
  7.  
  8. function encrypt($plaintext, $key, $cipher, $iv) {
  9.     if (in_array($cipher, openssl_get_cipher_methods())) {
  10.         $ivlen = openssl_cipher_iv_length($cipher);
  11.         $ciphertext = openssl_encrypt($plaintext, $cipher, $key, $options = 0, $iv);
  12.         if ($ciphertext) {
  13.             return $ciphertext;
  14.         } else {
  15.             echo "Encryption error";
  16.         }
  17.     }
  18. }
  19.  
  20. function decrypt($ciphertext, $key, $cipher, $iv) {
  21.     if (in_array($cipher, openssl_get_cipher_methods())) {
  22.         $ivlen = openssl_cipher_iv_length($cipher);
  23.         $plaintext = openssl_decrypt($ciphertext, $cipher, $key, $options = 0, $iv);
  24.         if ($plaintext) {
  25.             return $plaintext;
  26.         } else {
  27.             echo "Decryption error";
  28.         }
  29.     }
  30. }
  31.  
  32. $result = encrypt($plaintext, $key, $cipher, $iv);
  33. echo "Valor encriptado: " . $result . "<br>";
  34.  
  35. $decryptedValue = decrypt($result, $key, $cipher, $iv);
  36. echo "Valor desencriptado: " . $decryptedValue;
File Description
  • asdas
  • PHP Code
  • 31 Mar-2024
  • 1.15 Kb
You can Share it: