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

[BUG]: phalcon4 crypt performance #15118

Closed
davidcorreia opened this issue Jul 27, 2020 · 4 comments · Fixed by #15160
Closed

[BUG]: phalcon4 crypt performance #15118

davidcorreia opened this issue Jul 27, 2020 · 4 comments · Fixed by #15160
Assignees
Labels
bug A bug report

Comments

@davidcorreia
Copy link

I have upgraded the project on php7.3 from phalcon 3 to phalcon 4. One thing i have notice, is that the load from the server have increased alot...

one big change i saw was in Phalcon/Crypt

service.php

  $di->setShared('crypt', function () {
    $crypt = new Crypt();
    // Set a global encryption key
    $crypt->setKey('a really long key, 128 chars');

    return $crypt;
  });

Example: phalcon3

    $start = microtime(true);
    $crypt = Phalcon\Di::getDefault()->getCrypt();
    $name = $crypt->encryptBase64('teste name');
    for ($i = 0; $i < 1000000; $i++) {
        $crypt->decryptBase64($name);
    }
    echo microtime(true) - $start;

2,6897709369659

with phalcon 4 (same code)

26,91615819931

Is this normal behavior?

Thank you

dev & prod environment on php 7.3, tested on cli

@davidcorreia davidcorreia added bug A bug report status: unverified Unverified labels Jul 27, 2020
@Jeckerson
Copy link
Member

Jeckerson commented Jul 27, 2020

Fast tested on laptop:

  • 128 characters key - 54.802676916122 sec
  • 3 characters key - 57.090064048767 sec

Probably problem is not in key length.

@davidcorreia
Copy link
Author

i think the problem is with $crypt->decryptBase64() and not the key size

@zsilbi zsilbi linked a pull request Sep 29, 2020 that will close this issue
3 tasks
@zsilbi zsilbi added 4.1.0 and removed status: unverified Unverified labels Sep 29, 2020
@zsilbi zsilbi self-assigned this Sep 29, 2020
@zsilbi
Copy link
Member

zsilbi commented Sep 29, 2020

Fixed in #15160

@zsilbi zsilbi closed this as completed Sep 29, 2020
@zsilbi
Copy link
Member

zsilbi commented Sep 29, 2020

i think the problem is with $crypt->decryptBase64() and not the key size

The problem was that the available openssl ciphers were collected and checked before every decrypt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants