Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phalcon\Crypt safe base64 padding #12490

Merged
merged 2 commits into from
Jun 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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