Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #52 from AntoineLemaire/openssl-bug-fix
Browse files Browse the repository at this point in the history
Fix OpenSSL encrypt ZERO_PADDING
  • Loading branch information
CharlelieBouvier authored Jan 3, 2020
2 parents 3fb6779 + ac53f39 commit bdf22f5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Payline/PaylineSDK.php
Original file line number Diff line number Diff line change
Expand Up @@ -2309,7 +2309,15 @@ public function getEncrypt($message, $accessKey)
$opts = OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING;

$pad = 16;
$message .= str_repeat(chr($pad), $pad);
$len = strlen($message);

$padlen = $len + $pad - $len % $pad;
$message = str_pad(
$message,
$padlen,
chr($padlen - $len)
);

$encrypted = openssl_encrypt($message, $cipher, $accessKey, $opts);

return $this->base64_url_encode($encrypted);
Expand Down

0 comments on commit bdf22f5

Please sign in to comment.