You are here

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

Decrypt text.

Parameters

string $text: The text to be decrypted.

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

Return value

string The decrypted text

Throws

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

\Drupal\encrypt\Exception\EncryptionMethodCanNotDecryptException The method should throw this exception when the plugin can not decrypt (i.e. use a public key).

Overrides EncryptionMethodInterface::decrypt

File

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

Class

RealAESEncryptionMethod
Class RealAESEncryptionMethod.

Namespace

Drupal\real_aes\Plugin\EncryptionMethod

Code

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