3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php //Enter your code here, enjoy! function hmac($algo,$data,$passwd){ /* md5 and sha1 only */ $algo=strtolower($algo); //echo $algo; $p=array('md5'=>'greatherH32','sha1'=>'H40'); if(strlen($passwd)>64) { $passwd=pack($p[$algo],$algo($passwd)); //echo 'pass greater than 64'.chr(13); //echo $passwd; } if(strlen($passwd)<64) { $passwd=str_pad($passwd,64,chr(0)); //echo 'pass smaller than 64'.chr(13); //echo $passwd; } $ipad=substr($passwd,0,64) ^ str_repeat(chr(0x36),64); #echo 'ipad: '.$ipad.chr(13); $opad=substr($passwd,0,64) ^ str_repeat(chr(0x5C),64); echo 'Hex IPAD'.bin2hex($ipad).$opad.chr(13); echo 'Hex OPAD'.bin2hex($opad).$opad.chr(13); '#echo 'opad: '.$opad.chr(13); $hashedIpadData =$algo($ipad.$data); echo 'hashedIpadData: '.$hashedIpadData.chr(13); $packedIpdatData=pack($p[$algo],$hashedIpadData); echo 'packedIpdatData: '.$packedIpdatData.chr(13); $opadPack = $opad.$packedIpdatData; echo 'opadPack: '.$opadPack.chr(13); return $algo($opadPack); } # XXX ePay.bg URL (https://devep2.datamax.bg/ep2/epay2_demo/ if POST to DEMO system) $submit_url = 'https://devep2.datamax.bg/ep2/epay2_demo/'; # XXX Secret word with which merchant make CHECKSUM on the ENCODED packet $secret = 'YYBW64GVCVRRP5759A0QFDRXBYZQF5HV3SLTYN14RTWGRPTX8YF2R5UUET7BCT6E'; $min = 'D544248794'; $invoice = '173910'; # XXX Invoice $sum = '16.99'; # XXX Ammount $exp_date = '08.01.2014 12:24:44'; # XXX Expiration date $descr = 'Order: 173910, Product: 9626'; # XXX Description $data = <<<DATA MIN={$min} INVOICE={$invoice} AMOUNT={$sum} EXP_TIME={$exp_date} DESCR={$descr} ENCODING=utf-8 DATA; # XXX Packet: # (MIN or EMAIL)= REQUIRED # INVOICE= REQUIRED # AMOUNT= REQUIRED # EXP_TIME= REQUIRED # DESCR= OPTIONAL $ENCODED = base64_encode($data); $CHECKSUM = hmac('sha1', $ENCODED, $secret); # XXX SHA-1 algorithm REQUIRED echo mb_internal_encoding() . '<br />'; echo mb_regex_encoding(); echo <<<HTML <HTML> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1251"> </head> <BODY TEXT=#000000 BGCOLOR=#FFFFFF> <p>{$ENCODED}</p> <p>{$CHECKSUM}</p> HTML; ?>
Output for 5.4.0 - 5.4.23
Parse error: syntax error, unexpected 'opad' (T_STRING) in /in/e0GgX on line 31
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_STRING in /in/e0GgX on line 31
Process exited with code 255.