You are here

function _encryptfapi_encrypt_element_value in Encrypt Form API 7.2

Helper function to encrypt an element's value.

Parameters

$element: The element with the value to encrypt.

Return value

string The encrypted value.

1 call to _encryptfapi_encrypt_element_value()
_encryptfapi_encrypt_element in ./encryptfapi.module
Helper function to recursively process an element for encryption.

File

./encryptfapi.module, line 102
Main module file for Encrypt Form API.

Code

function _encryptfapi_encrypt_element_value($element, $value) {
  $encrypt = $element['#encrypt'];

  // If the value is an array, serialize it.
  if (is_array($value)) {
    $value = serialize($value);
  }
  if (is_array($encrypt)) {
    $config = isset($encrypt['config']) ? $encrypt['config'] : NULL;
    $options = isset($encrypt['options']) ? $encrypt['options'] : NULL;
    $encrypted_value = encrypt($value, $options, NULL, NULL, $config);
  }
  else {
    $encrypted_value = encrypt($value);
  }
  return $encrypted_value;
}