How to add zero byte padding in phpseclib with encryption method 3des in EBC mode?
Here my current code:
$cipher = new TripleDES(TripleDES::MODE_ECB);
$cipher->setKey('1234567890ABCDEFGHIJKLMN');
Just figure it out:
Disable padding: <hack
$cipher->disablePadding();
Manually pad message (depending on size here I used multiple of 8): <hack
$message_padded = $urlencoded;
if (strlen($message_padded) % 8) {
$message_padded = str_pad($message_padded,
strlen($message_padded) + 8 - strlen($message_padded) % 8, "\0");
}
encrypt: <hack
$result = $cipher -> encrypt($message_padded);