You are here

protected function WebformEncryptSubmissionStorage::decrypt in Webform Encrypt 8

Decrypts a string.

Parameters

string $data: The serialized submission data to be decrypted.

bool $check_permissions: Flag that controls permissions check.

Return value

string The decrypted value.

Throws

\Drupal\encrypt\Exception\EncryptException

2 calls to WebformEncryptSubmissionStorage::decrypt()
WebformEncryptSubmissionStorage::decryptChildren in src/WebformEncryptSubmissionStorage.php
Helper function to recursively decrypt children of fields.
WebformEncryptSubmissionStorage::decryptElements in src/WebformEncryptSubmissionStorage.php
Helper function to recursively decrypt fields.

File

src/WebformEncryptSubmissionStorage.php, line 168

Class

WebformEncryptSubmissionStorage
Alter webform submission storage definitions.

Namespace

Drupal\webform_encrypt

Code

protected function decrypt($data, $check_permissions = TRUE) {
  if ($check_permissions && !$this->currentUser
    ->hasPermission('view encrypted values')) {
    return '[Value Encrypted]';
  }
  $unserialized = unserialize($data);
  if (isset($unserialized['data']) && isset($unserialized['encrypt_profile'])) {
    $encryption_profile = EncryptionProfile::load($unserialized['encrypt_profile']);
    return $this->encryptionService
      ->decrypt($unserialized['data'], $encryption_profile);
  }
  return $data;
}