You are here

public function RealAESEncryptionMethod::checkDependencies in Real AES 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/EncryptionMethod/RealAESEncryptionMethod.php \Drupal\real_aes\Plugin\EncryptionMethod\RealAESEncryptionMethod::checkDependencies()

Check dependencies for the encryption method.

Parameters

string $text: The text to be checked.

string $key: The key to be checked.

Return value

array An array of error messages, providing info on missing dependencies.

Overrides EncryptionMethodInterface::checkDependencies

File

src/Plugin/EncryptionMethod/RealAESEncryptionMethod.php, line 30
Contains \Drupal\real_aes\Plugin\EncryptionMethod\RealAESEncryptionMethod.

Class

RealAESEncryptionMethod
Class RealAESEncryptionMethod.

Namespace

Drupal\real_aes\Plugin\EncryptionMethod

Code

public function checkDependencies($text = NULL, $key = NULL) {
  $errors = array();
  if (!class_exists('\\Defuse\\Crypto\\Crypto')) {
    $errors[] = t('Defuse PHP Encryption library is not correctly installed.');
  }

  // Check if we have a 128 bit key.
  if (strlen($key) != 16) {
    $errors[] = t('This encryption method requires a 128 bit key.');
  }
  return $errors;
}