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

feat(classes) PS 1.5-1.7+ Cypher #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lea-BMS
Copy link

@lea-BMS lea-BMS commented Jan 22, 2024

Provides different stubs for PrestaShop cypher classes

@lea-BMS
Copy link
Author

lea-BMS commented Jan 23, 2024

Sample use-case:

/**
 * Get cross-version compatible cypher class
 *
 * @return Blowfish|PhpEncryption|Rijndael
 */
function getCipher()
{
    if (version_compare(_PS_VERSION_, '1.7', '>=') &&
        defined('_NEW_COOKIE_KEY_')) {
        return new PhpEncryption(_NEW_COOKIE_KEY_);
    } else {
        if (!defined('_RIJNDAEL_KEY_')) {
            return new Blowfish(_COOKIE_KEY_, _COOKIE_IV_);
        }
        return new Rijndael(_RIJNDAEL_KEY_, _RIJNDAEL_IV_);
    }
}

$secret = getCypher->encrypt('foo bar baz cuux');
echo getCypher->decrypt($secret);

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

Successfully merging this pull request may close these issues.

1 participant