You are here

public function RealAESEncryptionMethod::encrypt 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::encrypt()

Encrypt text.

Parameters

string $text: The text to be encrypted.

string $key: The key to encrypt the text with.

Return value

string The encrypted text

Throws

\Drupal\encrypt\Exception\EncryptException Thrown when encryption fails.

Overrides EncryptionMethodInterface::encrypt

File

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

Class

RealAESEncryptionMethod
Class RealAESEncryptionMethod.

Namespace

Drupal\real_aes\Plugin\EncryptionMethod

Code

public function encrypt($text, $key, $options = array()) {
  try {
    return Crypto::encrypt($text, $key);
  } catch (Ex\CryptoTestFailed $ex) {
    return FALSE;
  } catch (Ex\CannotPerformOperation $ex) {
    return FALSE;
  }
}