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 'opad: '.$opad.chr(13); $hashedIpadData =$algo($ipad.$data); echo 'hashedIpadData: '.$hashedIpadData.chr(13); $packedIpdatData=utf8_encode(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 = '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 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.6.8 - 7.1.0
sha1pass smaller than 64 secretipad: ESUDSB6666666666666666666666666666666666666666666666666666666666 opad: /9?.9(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ hashedIpadData: 2437acee736688b761f456623316709e87639314 packedIpdatData: $7¬îsfˆ·aôVb3pž‡c“ opadPack: /9?.9(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\$7¬îsfˆ·aôVb3pž‡c“ UTF-8<br />UTF-8<HTML> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1251"> </head> <BODY TEXT=#000000 BGCOLOR=#FFFFFF> <p>TUlOPUQ1NDQyNDg3OTQKSU5WT0lDRT0xMjM0CkFNT1VOVD0yMi44MApFWFBfVElNRT0wMS4wOC4yMDIwCkRFU0NSPVRlc3Q=</p> <p>0c1b1f54815230eb52043495ebad390f8a8d22fc</p>
Output for 4.3.4 - 4.4.9, 5.3.0 - 5.5.35
sha1pass smaller than 64 secretipad: ESUDSB6666666666666666666666666666666666666666666666666666666666 opad: /9?.9(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ hashedIpadData: 2437acee736688b761f456623316709e87639314 packedIpdatData: $7¬îsfˆ·aôVb3pž‡c“ opadPack: /9?.9(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\$7¬îsfˆ·aôVb3pž‡c“ ISO-8859-1<br />EUC-JP<HTML> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1251"> </head> <BODY TEXT=#000000 BGCOLOR=#FFFFFF> <p>TUlOPUQ1NDQyNDg3OTQKSU5WT0lDRT0xMjM0CkFNT1VOVD0yMi44MApFWFBfVElNRT0wMS4wOC4yMDIwCkRFU0NSPVRlc3Q=</p> <p>0c1b1f54815230eb52043495ebad390f8a8d22fc</p>
Output for 5.0.0 - 5.2.17
sha1pass smaller than 64 secretipad: ESUDSB6666666666666666666666666666666666666666666666666666666666 opad: /9?.9(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ hashedIpadData: 2437acee736688b761f456623316709e87639314 packedIpdatData: $7¬îsfˆ·aôVb3pž‡c“ opadPack: /9?.9(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\$7¬îsfˆ·aôVb3pž‡c“ ISO-8859-1<br />ISO-8859-1<HTML> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1251"> </head> <BODY TEXT=#000000 BGCOLOR=#FFFFFF> <p>TUlOPUQ1NDQyNDg3OTQKSU5WT0lDRT0xMjM0CkFNT1VOVD0yMi44MApFWFBfVElNRT0wMS4wOC4yMDIwCkRFU0NSPVRlc3Q=</p> <p>0c1b1f54815230eb52043495ebad390f8a8d22fc</p>
Output for 4.3.3
sha1pass smaller than 64 secretipad: ESUDSB6666666666666666666666666666666666666666666666666666666666 opad: /9?.9(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ hashedIpadData: 2437acee736688b761f456623316709e87639314 packedIpdatData: $7¬îsfˆ·aôVb3pž‡c“ opadPack: /9?.9(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\$7¬îsfˆ·aôVb3pž‡c“ ISO-8859-1<br /> Fatal error: Call to undefined function: mb_regex_encoding() in /in/kquvp on line 71
Process exited with code 255.
Output for 4.3.2
sha1pass smaller than 64 secretipad: ESUDSB6666666666666666666666666666666666666666666666666666666666 opad: /9?.9(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ hashedIpadData: 2437acee736688b761f456623316709e87639314 packedIpdatData: $7¬îsfˆ·aôVb3pž‡c“ opadPack: /9?.9(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\$7¬îsfˆ·aôVb3pž‡c“ pass<br /> Fatal error: Call to undefined function: mb_regex_encoding() in /in/kquvp on line 71
Process exited with code 255.
Output for 4.3.0 - 4.3.1
sha1pass smaller than 64 secretipad: ESUDSB6666666666666666666666666666666666666666666666666666666666 opad: /9?.9(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ hashedIpadData: 2437acee736688b761f456623316709e87639314 packedIpdatData: $7¬îsfˆ·aôVb3pž‡c“ opadPack: /9?.9(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\$7¬îsfˆ·aôVb3pž‡c“ pass<br /> Fatal error: Call to undefined function: mb_regex_encoding() in /in/kquvp on line 71