Skip to content

Commit

Permalink
Merge pull request #12490 from tugrul/crypt_base64_padding
Browse files Browse the repository at this point in the history
Phalcon\Crypt safe base64 padding
  • Loading branch information
sergeyklay authored Jun 18, 2017
2 parents 8b641b9 + cf4f3b8 commit 3f8f1c1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions phalcon/crypt.zep
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ class Crypt implements CryptInterface
public function encryptBase64(string! text, key = null, boolean! safe = false) -> string
{
if safe == true {
return strtr(base64_encode(this->encrypt(text, key)), "+/", "-_");
return rtrim(strtr(base64_encode(this->encrypt(text, key)), "+/", "-_"), "=");
}
return base64_encode(this->encrypt(text, key));
}
Expand All @@ -383,7 +383,7 @@ class Crypt implements CryptInterface
public function decryptBase64(string! text, key = null, boolean! safe = false) -> string
{
if safe == true {
return this->decrypt(base64_decode(strtr(text, "-_", "+/")), key);
return this->decrypt(base64_decode(strtr(text, "-_", "+/") . substr("===", (strlen(text) + 3) % 4)), key);
}
return this->decrypt(base64_decode(text), key);
}
Expand Down

0 comments on commit 3f8f1c1

Please sign in to comment.