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 get_md5_hash($string) { return strtolower(md5($string)); } fu..

Decoded Output download

<?php 
 
function get_md5_hash($string) { 
    return strtolower(md5($string)); 
} 
 
 
function generate_token($appId, $secretKey) { 
    $timestamp = time(); 
    $randomStr = rand(100000, 999999); 
    $transId = "$timestamp$randomStr"; 
 
     
    $toHash = "appkey$appId" . "timestamp$timestamp" . "transid$transId" . $secretKey; 
    $token = get_md5_hash($toHash); 
 
    return [ 
        'transId' => $transId, 
        'timestamp' => $timestamp, 
        'token' => $token 
    ]; 
} 
 
 
$apiUrl = "https://xcx.apsatcom.com/OSN/api/prod/terminal/status/v1"; 
$appId = "teleglobal"; 
$secretKey = "xsS90rhYogaXkaxNNKCwnFiQiGT522kE"; 
 
 
$terminalIds = isset($_POST['terminalId']) ? array_map('trim', explode(',', $_POST['terminalId'])) : []; 
 
 
$tokenInfo = generate_token($appId, $secretKey); 
 
 
$headers = [ 
    "Content-Type: application/json", 
    "Authorization: Bearer " . $tokenInfo['token'] 
]; 
 
 
$body = [ 
    "APSTAR_HEAD" => [ 
        "APP_ID" => $appId, 
        "TIMESTAMP" => $tokenInfo['timestamp'], 
        "TRANS_ID" => $tokenInfo['transId'], 
        "TOKEN" => $tokenInfo['token'] 
    ], 
    "APSTAR_BODY" => [ 
        "terminalids" => $terminalIds 
    ] 
]; 
 
$options = [ 
    CURLOPT_URL => $apiUrl, 
    CURLOPT_RETURNTRANSFER => true, 
    CURLOPT_POST => true, 
    CURLOPT_POSTFIELDS => json_encode($body), 
    CURLOPT_HTTPHEADER => $headers, 
    CURLOPT_SSL_VERIFYPEER => false,   
    CURLOPT_VERBOSE => true,   
    CURLOPT_STDERR => fopen('php://stderr', 'w')   
]; 
 
$ch = curl_init(); 
curl_setopt_array($ch, $options); 
$response = curl_exec($ch); 
$err = curl_error($ch); 
curl_close($ch); 
 
$responseData = []; 
if ($err) { 
    $error = "cURL Error #:" . $err; 
} else { 
    $responseData = json_decode($response, true); 
} 
 
?>

Did this file decode correctly?

Original Code

<?php

function get_md5_hash($string) {
    return strtolower(md5($string));
}


function generate_token($appId, $secretKey) {
    $timestamp = time();
    $randomStr = rand(100000, 999999);
    $transId = "$timestamp$randomStr";

    
    $toHash = "appkey$appId" . "timestamp$timestamp" . "transid$transId" . $secretKey;
    $token = get_md5_hash($toHash);

    return [
        'transId' => $transId,
        'timestamp' => $timestamp,
        'token' => $token
    ];
}


$apiUrl = "https://xcx.apsatcom.com/OSN/api/prod/terminal/status/v1";
$appId = "teleglobal";
$secretKey = "xsS90rhYogaXkaxNNKCwnFiQiGT522kE";


$terminalIds = isset($_POST['terminalId']) ? array_map('trim', explode(',', $_POST['terminalId'])) : [];


$tokenInfo = generate_token($appId, $secretKey);


$headers = [
    "Content-Type: application/json",
    "Authorization: Bearer " . $tokenInfo['token']
];


$body = [
    "APSTAR_HEAD" => [
        "APP_ID" => $appId,
        "TIMESTAMP" => $tokenInfo['timestamp'],
        "TRANS_ID" => $tokenInfo['transId'],
        "TOKEN" => $tokenInfo['token']
    ],
    "APSTAR_BODY" => [
        "terminalids" => $terminalIds
    ]
];

$options = [
    CURLOPT_URL => $apiUrl,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => json_encode($body),
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_SSL_VERIFYPEER => false,  
    CURLOPT_VERBOSE => true,  
    CURLOPT_STDERR => fopen('php://stderr', 'w')  
];

$ch = curl_init();
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);

$responseData = [];
if ($err) {
    $error = "cURL Error #:" . $err;
} else {
    $responseData = json_decode($response, true);
}

?>

Function Calls

None

Variables

None

Stats

MD5 6aea93848ff4aa9ae8f155cda00a3ce8
Eval Count 0
Decode Time 36 ms