You are here

trait FieldEncyptCacheTrait in Field Encryption 7

Class FieldEncyptCacheTrait.

Hierarchy

File

./field_encrypt.cache.inc, line 11
Field encryption cache classes.

View source
trait FieldEncyptCacheTrait {

  /**
   * Encrypts the data for the Cache backend.
   *
   * @param mixed $data
   *   Decrypted data.
   *
   * @return string
   *   Encrypted data string.
   */
  private function encrypt($data) {
    if (!is_string($data)) {
      $data = serialize($data);
    }

    // Encrypt the data just before it's saved.
    module_load_include('inc', 'field_encrypt');
    return field_encrypt_encrypt($data);
  }

  /**
   * Decrypts the data from the Cache backend.
   *
   * @param string $data
   *   Encrypted data string.
   *
   * @return mixed|string
   *   Decrypted data.
   */
  private function decrypt($data) {
    module_load_include('inc', 'field_encrypt');
    return field_encrypt_decrypt($data);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FieldEncyptCacheTrait::decrypt private function Decrypts the data from the Cache backend.
FieldEncyptCacheTrait::encrypt private function Encrypts the data for the Cache backend.