ttt - 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 ttt.php

  1. <?php
  2.         $api_secret = '$2y$10$7r/5ypnAo/yl2tdzciapbuuEJYxi3HawvUirItSsnrWseP0VcvWQK';
  3.         $data = '359883430246';
  4.         $strong = true;
  5.         $options = 0;
  6.         $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'), $strong);
  7.         $encrypted = openssl_encrypt($data, 'aes-256-cbc', $api_secret, $options, $iv);
  8.         $encryptedWithsalt = $iv.$encrypted;
  9.         $encrypted_data = base64_encode($encryptedWithsalt);
  10.         
  11.         echo 'iv(base 64): '.base64_encode($iv)."\n";
  12.         echo 'encrypted(base 64): '.$encrypted."\n";
  13.         echo 'encrypted with salt: '.$encryptedWithsalt."\n";
  14.         echo 'encrypted with salt(base 64 ): '.$encrypted_data."\n";
  15.         
  16.         $data = base64_decode($encrypted_data);
  17.         $iv_length = openssl_cipher_iv_length('aes-256-cbc');
  18.         $iv = substr($data, 0, $iv_length);
  19.         $data = substr($data, $iv_length);
  20.         $data = openssl_decrypt($data, 'aes-256-cbc', $api_secret, $options, $iv);
  21.  
  22.         echo 'decrypted: '.$data."\n";
File Description
  • ttt
  • PHP Code
  • 12 Apr-2022
  • 1.03 Kb
You can Share it: