You are here

public static function WebformContentCreatorUtilities::getDecryptedValue in Webform Content Creator 3.x

Same name and namespace in other branches
  1. 8 src/WebformContentCreatorUtilities.php \Drupal\webform_content_creator\WebformContentCreatorUtilities::getDecryptedValue()
  2. 2.x src/WebformContentCreatorUtilities.php \Drupal\webform_content_creator\WebformContentCreatorUtilities::getDecryptedValue()

Get decrypted value.

Parameters

string $value: Encrypted value.

string $encryption_profile: Encryption profile.

Return value

string Decrypted value

2 calls to WebformContentCreatorUtilities::getDecryptedValue()
WebformContentCreatorEntity::getDecryptionFromProfile in src/Entity/WebformContentCreatorEntity.php
Get decrypted value with the configured encryption profile.
WebformContentCreatorUtilities::getTokenValue in src/WebformContentCreatorUtilities.php
Get values inside text with tokens.

File

src/WebformContentCreatorUtilities.php, line 337

Class

WebformContentCreatorUtilities
Provides useful functions required in Webform content creator module.

Namespace

Drupal\webform_content_creator

Code

public static function getDecryptedValue($value, $encryption_profile) {
  $result = FALSE;
  if (empty($value) || empty($encryption_profile)) {
    return '';
  }
  if (\Drupal::service('module_handler')
    ->moduleExists('encrypt')) {
    $result = \Drupal::service('encryption')
      ->decrypt($value, $encryption_profile);
  }
  if ($result === FALSE) {
    $result = $value;
  }
  return $result;
}