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'; echo $passwd; } if(strlen($passwd)<64) { $passwd=str_pad($passwd,64,chr(0)); echo 'pass smaller than 64'; echo $passwd; } $ipad=substr($passwd,0,64) ^ str_repeat(chr(0x36),64); echo 'ipad: $ipad'; $opad=substr($passwd,0,64) ^ str_repeat(chr(0x5C),64); echo 'opad: $opad'; return($algo($opad.pack($p[$algo],$algo($ipad.$data)))); } # 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 = 'secret'; $min = 'D544248794'; $invoice = 1234; # XXX Invoice $sum = '22.80'; # XXX Ammount $exp_date = '01.08.2020'; # XXX Expiration date $descr = 'Test'; # XXX Description $data = <<<DATA MIN={$min} INVOICE={$invoice} AMOUNT={$sum} EXP_TIME={$exp_date} DESCR={$descr} 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 <<<HTML <HTML> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1251"> </head> <BODY TEXT=#000000 BGCOLOR=#FFFFFF> <BR> <BR> <CENTER><h1>DEMO</h1> <TABLE border=1> <form action="{$submit_url}" method=POST> <input type=hidden name=PAGE value="paylogin"> <input type=hidden name=ENCODED value="{$ENCODED}"> <input type=hidden name=CHECKSUM value="{$CHECKSUM}"> <input type=hidden name=URL_OK value="SET_URL_OK_IF_NEEDED"> <input type=hidden name=URL_CANCEL value="SET_URL_CANCEL_IF_NEEDED"> <TR> <TD>ÌÈÍ: {$min}</TD> </TR> <TR> <TD>Ôàêòóðà íîìåð: {$invoice}</TD> </TR> <TR> <TD>Îïèñàíèå: {$descr}</TD> </TR> <TR> <TD> <xmp> Ïðîäóêòè êîë. åä.öåíà öåíà ------------------------------------------------ ïðîäóêò1 3 2.50 7.50 ïðîäóêò2 1 3.50 3.50 ïðîäóêò3 2 4.00 8.00 ------------------------------------------------ îáùî 19.00 ÄÄÑ 3.80 Âñè÷êî {$sum} </xmp> </TD> </TR> <TR> <TD>Ñóìà: {$sum}</TD> </TR> </table> <table width=100%> <TR align=center> <TD><INPUT type=submit></TD> </TR> </TABLE> </form> </BODY> </HTML> HTML; ?>
Output for 4.3.0 - 7.1.0
sha1pass smaller than 64secretipad: $ipadopad: $opad<HTML> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1251"> </head> <BODY TEXT=#000000 BGCOLOR=#FFFFFF> <BR> <BR> <CENTER><h1>DEMO</h1> <TABLE border=1> <form action="https://devep2.datamax.bg/ep2/epay2_demo/" method=POST> <input type=hidden name=PAGE value="paylogin"> <input type=hidden name=ENCODED value="TUlOPUQ1NDQyNDg3OTQKSU5WT0lDRT0xMjM0CkFNT1VOVD0yMi44MApFWFBfVElNRT0wMS4wOC4yMDIwCkRFU0NSPVRlc3Q="> <input type=hidden name=CHECKSUM value="6a66f506e98b21038147fe28b77abcfc0bd156b3"> <input type=hidden name=URL_OK value="SET_URL_OK_IF_NEEDED"> <input type=hidden name=URL_CANCEL value="SET_URL_CANCEL_IF_NEEDED"> <TR> <TD>ÌÈÍ: D544248794</TD> </TR> <TR> <TD>Ôàêòóðà íîìåð: 1234</TD> </TR> <TR> <TD>Îïèñàíèå: Test</TD> </TR> <TR> <TD> <xmp> Ïðîäóêòè êîë. åä.öåíà öåíà ------------------------------------------------ ïðîäóêò1 3 2.50 7.50 ïðîäóêò2 1 3.50 3.50 ïðîäóêò3 2 4.00 8.00 ------------------------------------------------ îáùî 19.00 ÄÄÑ 3.80 Âñè÷êî 22.80 </xmp> </TD> </TR> <TR> <TD>Ñóìà: 22.80</TD> </TR> </table> <table width=100%> <TR align=center> <TD><INPUT type=submit></TD> </TR> </TABLE> </form> </BODY> </HTML>