This WordPress bundle integrates defuse/php-encryption in applications based on snicco/kernel.
Make sure you have a read the documentation of defuse/php-encryption.
composer install snicco/encryption-bundleSee config/encryption.php for the available configuration options.
If this file does not exist in your configuration directory the default configuration will be copied the first time the kernel is booted in dev mode.
The EncryptionOption::KEY_ASCII is intentionally set to a value that will throw an exception.
MAKE SURE TO READ THE DOCUMENTATION IN THE config/encryption.php FILE.
You must first generate a valid defuse key by running:
vendor/bin/vendor/bin/generate-defuse-keyMAKE SURE TO READ THE DOCUMENTATION IN THE config/encryption.php FILE to determine the best way to load the output of the above command into your configuration.
Add the EncryptionBundle to your bundles.php
config file.
<?php
// /path/to/configuration/bundles.php
use Snicco\Bundle\Encryption\EncryptionBundle;
return [
'bundles' => [
Snicco\Component\Kernel\ValueObject\Environment::ALL => [
EncryptionBundle::class
]
]
];You can now lazily resolve the DefuseEncryptor from the booted kernel.
use Snicco\Bundle\Encryption\DefuseEncryptor;
use Snicco\Component\Kernel\Kernel;
/**
* @var Kernel $kernel
*/
$kernel->boot();
$defuse = $kernel->container()->make(DefuseEncryptor::class);
$plaintext = 'snicco.io';
$ciphertext = $defuse->encrypt($plaintext);
var_dump($plaintext === $ciphertext); // false
$plain2 = $defuse->decrypt($ciphertext);
var_dump($plaintext === $plain2); // true This repository is a read-only split of the development repo of the Snicco project.
This is how you can contribute.
Please report issues in the Snicco monorepo.
If you discover a security vulnerability within BetterWPCache, please follow our disclosure procedure.