I'm trying to load in a composer package: archwisp/php-encrypt-data, and while I'm able to use it in a test php script, using it in Drupal itself doesn't seem to be working.
This is the test script:
require __DIR__ . '/vendor/autoload.php'; $encryptionKey = 'IyJQdVtyNClqQ+ybuxHWNhJnw93ocxJuLruRztQPNI0='; $macKey = 'pbJqXp4YhhtRYv/Ntt/i+O4KbO1F4/2bktO08m0+Exo='; $phpcrypt = new \PHPEncryptData\Simple($encryptionKey, $macKey); $ciphertext = $phpcrypt->encrypt('Foobar'); echo $ciphertext . "\n"; echo $phpcrypt->decrypt($ciphertext) . "\n";
But, I don't understand what I have to do in a Drupal class to make this work. I tried to
use archwisp\PHPEncryptData; at the top of the file, and I tried doing
require DRUPAL_ROOT . '/vendor/autoload.php'; as well, but no matter what, it always says:
Call to undefined function PHPEncryptData\\mcrypt_get_key_size()
Is it because it didn't do the autoload the same way, or is it getting mixed up because of namespaces? The error is coming from the composer package itself, so it is locating that, but for some reason it's not calling the mcrypt function correctly, even though the extension is enabled and working in the test script.