public function EncryptService::decrypt in Encrypt 8.3
Main decrypt function.
Parameters
string $text: The encrypted text to decrypt.
\Drupal\encrypt\EncryptionProfileInterface $encryption_profile: The encryption profile entity.
Return value
string The decrypted plain string.
Throws
\Drupal\encrypt\Exception\EncryptException Can throw an EncryptException.
\Drupal\encrypt\Exception\EncryptionMethodCanNotDecryptException Thrown when method can not decrypt (i.e. use a public key).
Overrides EncryptServiceInterface::decrypt
File
- src/
EncryptService.php, line 87
Class
- EncryptService
- Class EncryptService.
Namespace
Drupal\encryptCode
public function decrypt($text, EncryptionProfileInterface $encryption_profile) {
if (!$encryption_profile
->getEncryptionMethod()
->canDecrypt()) {
throw new EncryptionMethodCanNotDecryptException();
}
if ($this
->validate($text, $encryption_profile)) {
$key = $encryption_profile
->getEncryptionKey();
return $encryption_profile
->getEncryptionMethod()
->decrypt($text, $key
->getKeyValue());
}
}