Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php function encrypt_decrypt($action, $string) { $output = false; $encrypt..

Decoded Output download

<?php 
function encrypt_decrypt($action, $string) 
{ 
    $output = false; 
 
    $encrypt_method = "AES-256-CBC"; 
    $secret_key = '9S2R492UI4'; 
    $secret_iv = '4D9H8'; 
 
    // hash 
    $key = hash('sha256', $secret_key); 
 
    // iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning 
    $iv = substr(hash('sha256', $secret_iv), 0, 16); 
 
    if ($action == 'e') { 
        $output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv); 
        $output = base64_encode($output); 
    } else if ($action == 'd') { 
        $output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv); 
    } 
 
    return $output; 
} 
 
echo encrypt_decrypt('d', 'REZ4T0YwMU1jR2FaQzRxY3diWE9TZz09'); ?>

Did this file decode correctly?

Original Code

<?php
function encrypt_decrypt($action, $string)
{
    $output = false;

    $encrypt_method = "AES-256-CBC";
    $secret_key = '9S2R492UI4';
    $secret_iv = '4D9H8';

    // hash
    $key = hash('sha256', $secret_key);

    // iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning
    $iv = substr(hash('sha256', $secret_iv), 0, 16);

    if ($action == 'e') {
        $output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
        $output = base64_encode($output);
    } else if ($action == 'd') {
        $output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
    }

    return $output;
}

echo encrypt_decrypt('d', 'REZ4T0YwMU1jR2FaQzRxY3diWE9TZz09');

Function Calls

hash 1
encrypt_decrypt 1

Variables

$action d
$output False
$string REZ4T0YwMU1jR2FaQzRxY3diWE9TZz09
$secret_iv 4D9H8
$secret_key 9S2R492UI4
$encrypt_method AES-256-CBC

Stats

MD5 11edfbed6ed08f4f8c5f7c7766f46b4d
Eval Count 0
Decode Time 78 ms