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.
Result of php executing
Full code of asdas.php
- <?php
- $plaintext = 'O:8:"userdata":3:{s:4:"role";s:4:"user";s:2:"id";i:70;s:3:"uid";i:72;}';
- $key = "8b362e210615e66b3bf7f69f6c819056";
- $cipher = "aes-256-ctr";
- $iv = "ABCDEFGHIJKLMNOP";
- function encrypt($plaintext, $key, $cipher, $iv) {
- if (in_array($cipher, openssl_get_cipher_methods())) {
- $ivlen = openssl_cipher_iv_length($cipher);
- $ciphertext = openssl_encrypt($plaintext, $cipher, $key, $options = 0, $iv);
- if ($ciphertext) {
- return $ciphertext;
- } else {
- echo "Encryption error";
- }
- }
- }
- function decrypt($ciphertext, $key, $cipher, $iv) {
- if (in_array($cipher, openssl_get_cipher_methods())) {
- $ivlen = openssl_cipher_iv_length($cipher);
- $plaintext = openssl_decrypt($ciphertext, $cipher, $key, $options = 0, $iv);
- if ($plaintext) {
- return $plaintext;
- } else {
- echo "Decryption error";
- }
- }
- }
- $result = encrypt($plaintext, $key, $cipher, $iv);
- echo "Valor encriptado: " . $result . "<br>";
- $decryptedValue = decrypt($result, $key, $cipher, $iv);
- echo "Valor desencriptado: " . $decryptedValue;