fork download
  1. <?php
  2.  
  3. // your code goes here
  4. function create_mpg_aes_encrypt ($parameter = "" , $key = "", $iv = "") {
  5.  
  6. $return_str = '';
  7.  
  8. if (!empty($parameter)) {
  9.  
  10. $return_str = http_build_query($parameter);
  11. }
  12.  
  13. echo mcrypt_encrypt(MCRYPT_RIJNDAEL_128,$key,addpadding($return_str), MCRYPT_MODE_CBC, $iv);
  14. return trim(bin2hex(mcrypt_encrypt(MCRYPT_RIJNDAEL_128,
  15.  
  16. $key,addpadding($return_str), MCRYPT_MODE_CBC, $iv)));
  17.  
  18. }
  19.  
  20. function addpadding($string, $blocksize = 32) {
  21.  
  22. $len = strlen($string);
  23.  
  24. $pad = $blocksize - ($len % $blocksize);
  25.  
  26. $string .= str_repeat(chr($pad), $pad);
  27.  
  28. return $string;
  29.  
  30. }
  31.  
  32. $query=array(
  33. 'MerchantID'=>"PG300000000055",
  34. 'Version'=>"1.0",
  35. 'TimeStamp'=>"1489630207",
  36. 'MerchantOrderNo'=>"S_1489630207",
  37. 'Amt'=>"30",
  38. 'ItmeDesc'=>"UnitTest"
  39. );
  40.  
  41. create_mpg_aes_encrypt($query,"12345678901234567890123456789012","1234567890123456");
  42.  
Runtime error #stdin #stdout #stderr 0.01s 82496KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Fatal error:  Uncaught Error: Call to undefined function mcrypt_encrypt() in /home/W0T5sg/prog.php:13
Stack trace:
#0 /home/W0T5sg/prog.php(41): create_mpg_aes_encrypt(Array, '123456789012345...', '123456789012345...')
#1 {main}
  thrown in /home/W0T5sg/prog.php on line 13