Can anyone help me translate this to PowerBuilder ?
$customerId = 108;
$user = "351130";
$password = "2ctobeR2018";
$aes_key = "NzQ3MGIyOWEyMDk0MzI3Y2RiNzlkMThjZGY5YTJmY2YzNzI1OTQxMw";
date_default_timezone_set("Asia/Singapore");
$password = sha1($password);
$ticket = $customerId.$user.$password.date('Ymd');
$IVsize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
$IV = substr(str_pad($aes_key, $IVsize, $aes_key), 0, $IVsize);
$keySize = mcrypt_get_key_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
$aes_key = substr(str_pad($aes_key, $keySize, $aes_key), 0, $keySize);
$BlockSize = mcrypt_get_block_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
$StringLength = strlen($ticket);
$Padding = $BlockSize - ($StringLength % $BlockSize);
$ticket .= str_repeat(chr($Padding), $Padding);
$ticket = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $aes_key, $ticket, MCRYPT_MODE_CBC, $IV);
$ticket = base64_encode($ticket);
$ticket = strtr($ticket, '+/=', '-_,');
echo "Ticket = '$ticket'";
?>
PHP output (changes according to date):
Ticket = 'pBFPX50um4iBVtdL1GhgMiB0RfVQYg1oHddcGngPmDVfPbOi7S96IKnVNFXG02FbFAZw4QtRj9H-7U_zRdn2FQ,,'
The password encode to SHA1 worked as advised by Arthur.
The codes in between, I believe are just string manipulations, (substr, str_pad, strlen, etc.)
But now I am stuck at these lines:
$ticket = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $aes_key, $ticket, MCRYPT_MODE_CBC, $IV);
$ticket = base64_encode($ticket);
Any help appreciated. I'm not getting the expected PHP output as above.
Powerbuilder:
Blob lblb_data
lblb_data = lnv_CrypterObject.SymmetricEncrypt (AES!, Blob (ls_ticket_pad, EncodingANSI!), Blob (ls_aes, EncodingANSI!), OperationModeCBC!, Blob (ls_iv, EncodingANSI!), PKCSPadding!)
String ls_hex
ls_hex = lnv_CoderObject.HexEncode (lblb_data)
String ls_base64str
ls_base64str = lnv_CoderObject.Base64Encode (Blob (ls_hex, EncodingANSI!))
Any help appreciated. Thanks.
Regards, Kiat