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).chr(13); echo 'Hex OPAD'.bin2hex($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); echo 'packed to hex'.bin2hex($packedIpdatData); $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.6.0 - 5.6.28, 7.0.0 - 7.1.0
Hex IPAD6f6f74610002716075606464660301030f7706677072646e746f6c6770037e6005657a626f780702646261716466626e0e6f7004640363637362017475620073 Hex OPAD05051e0b6a681b0a1f0a0e0e0c696b69651d6c0d1a180e041e05060d1a69140a6f0f100805126d680e080b1b0e0c080464051a6e0e69090919086b1e1f086a19 hashedIpadData: 435b303b83bfba050668d2f11b15492ee8d3e04e packedIpdatData: C[0;���h��I.���N packed to hex435b303b83bfba050668d2f11b15492ee8d3e04eopadPack:  jh   ikiel  i omh  dni kjC[0;���h��I.���N 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>TUlOPUQ1NDQyNDg3OTQKSU5WT0lDRT0xNzM5MTAKQU1PVU5UPTE2Ljk5CkVYUF9USU1FPTA4LjAxLjIwMTQgMTI6MjQ6NDQKREVTQ1I9T3JkZXI6IDE3MzkxMCwgUHJvZHVjdDogOTYyNgpFTkNPRElORz11dGYtOA==</p> <p>7ed53925db5692f54705b0f7c31e22d4363bdf4f</p>
Output for hhvm-3.10.0 - 3.12.0
Hex IPAD6f6f74610002716075606464660301030f7706677072646e746f6c6770037e6005657a626f780702646261716466626e0e6f7004640363637362017475620073 Hex OPAD05051e0b6a681b0a1f0a0e0e0c696b69651d6c0d1a180e041e05060d1a69140a6f0f100805126d680e080b1b0e0c080464051a6e0e69090919086b1e1f086a19 hashedIpadData: 435b303b83bfba050668d2f11b15492ee8d3e04e packedIpdatData: C[0;���h��I.���N packed to hex435b303b83bfba050668d2f11b15492ee8d3e04eopadPack:  jh   ikiel  i omh  dni kjC[0;���h��I.���N UTF-8<br />EUC-JP<HTML> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1251"> </head> <BODY TEXT=#000000 BGCOLOR=#FFFFFF> <p>TUlOPUQ1NDQyNDg3OTQKSU5WT0lDRT0xNzM5MTAKQU1PVU5UPTE2Ljk5CkVYUF9USU1FPTA4LjAxLjIwMTQgMTI6MjQ6NDQKREVTQ1I9T3JkZXI6IDE3MzkxMCwgUHJvZHVjdDogOTYyNgpFTkNPRElORz11dGYtOA==</p> <p>7ed53925db5692f54705b0f7c31e22d4363bdf4f</p>
Output for 4.3.4 - 4.4.9, 5.3.0 - 5.5.38
Hex IPAD6f6f74610002716075606464660301030f7706677072646e746f6c6770037e6005657a626f780702646261716466626e0e6f7004640363637362017475620073 Hex OPAD05051e0b6a681b0a1f0a0e0e0c696b69651d6c0d1a180e041e05060d1a69140a6f0f100805126d680e080b1b0e0c080464051a6e0e69090919086b1e1f086a19 hashedIpadData: 435b303b83bfba050668d2f11b15492ee8d3e04e packedIpdatData: C[0;���h��I.���N packed to hex435b303b83bfba050668d2f11b15492ee8d3e04eopadPack:  jh   ikiel  i omh  dni kjC[0;���h��I.���N 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>TUlOPUQ1NDQyNDg3OTQKSU5WT0lDRT0xNzM5MTAKQU1PVU5UPTE2Ljk5CkVYUF9USU1FPTA4LjAxLjIwMTQgMTI6MjQ6NDQKREVTQ1I9T3JkZXI6IDE3MzkxMCwgUHJvZHVjdDogOTYyNgpFTkNPRElORz11dGYtOA==</p> <p>7ed53925db5692f54705b0f7c31e22d4363bdf4f</p>
Output for 5.0.0 - 5.2.17
Hex IPAD6f6f74610002716075606464660301030f7706677072646e746f6c6770037e6005657a626f780702646261716466626e0e6f7004640363637362017475620073 Hex OPAD05051e0b6a681b0a1f0a0e0e0c696b69651d6c0d1a180e041e05060d1a69140a6f0f100805126d680e080b1b0e0c080464051a6e0e69090919086b1e1f086a19 hashedIpadData: 435b303b83bfba050668d2f11b15492ee8d3e04e packedIpdatData: C[0;���h��I.���N packed to hex435b303b83bfba050668d2f11b15492ee8d3e04eopadPack:  jh   ikiel  i omh  dni kjC[0;���h��I.���N 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>TUlOPUQ1NDQyNDg3OTQKSU5WT0lDRT0xNzM5MTAKQU1PVU5UPTE2Ljk5CkVYUF9USU1FPTA4LjAxLjIwMTQgMTI6MjQ6NDQKREVTQ1I9T3JkZXI6IDE3MzkxMCwgUHJvZHVjdDogOTYyNgpFTkNPRElORz11dGYtOA==</p> <p>7ed53925db5692f54705b0f7c31e22d4363bdf4f</p>
Output for 4.3.3
Hex IPAD6f6f74610002716075606464660301030f7706677072646e746f6c6770037e6005657a626f780702646261716466626e0e6f7004640363637362017475620073 Hex OPAD05051e0b6a681b0a1f0a0e0e0c696b69651d6c0d1a180e041e05060d1a69140a6f0f100805126d680e080b1b0e0c080464051a6e0e69090919086b1e1f086a19 hashedIpadData: 435b303b83bfba050668d2f11b15492ee8d3e04e packedIpdatData: C[0;���h��I.���N packed to hex435b303b83bfba050668d2f11b15492ee8d3e04eopadPack:  jh   ikiel  i omh  dni kjC[0;���h��I.���N ISO-8859-1<br /> Fatal error: Call to undefined function: mb_regex_encoding() in /in/X32e5 on line 77
Process exited with code 255.
Output for 4.3.2
Hex IPAD6f6f74610002716075606464660301030f7706677072646e746f6c6770037e6005657a626f780702646261716466626e0e6f7004640363637362017475620073 Hex OPAD05051e0b6a681b0a1f0a0e0e0c696b69651d6c0d1a180e041e05060d1a69140a6f0f100805126d680e080b1b0e0c080464051a6e0e69090919086b1e1f086a19 hashedIpadData: 435b303b83bfba050668d2f11b15492ee8d3e04e packedIpdatData: C[0;���h��I.���N packed to hex435b303b83bfba050668d2f11b15492ee8d3e04eopadPack:  jh   ikiel  i omh  dni kjC[0;���h��I.���N pass<br /> Fatal error: Call to undefined function: mb_regex_encoding() in /in/X32e5 on line 77
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Hex IPAD6f6f74610002716075606464660301030f7706677072646e746f6c6770037e6005657a626f780702646261716466626e0e6f7004640363637362017475620073 Hex OPAD05051e0b6a681b0a1f0a0e0e0c696b69651d6c0d1a180e041e05060d1a69140a6f0f100805126d680e080b1b0e0c080464051a6e0e69090919086b1e1f086a19 hashedIpadData: 435b303b83bfba050668d2f11b15492ee8d3e04e packedIpdatData: C[0;���h��I.���N packed to hex435b303b83bfba050668d2f11b15492ee8d3e04eopadPack:  jh   ikiel  i omh  dni kjC[0;���h��I.���N pass<br /> Fatal error: Call to undefined function: mb_regex_encoding() in /in/X32e5 on line 77