0

One of my webform component is using Webform Encrypt. The Encrypt feature is from Encrypt and Key modules. I set the key and encrypt as following. Everything is working fine in the submission data, but how can I decrypt the encrypted data if I send the data to someone? I have been searching this for days with no solution. Some online AES calculator has "IV" input and I don't know where to get that information.

Key:
type type: AES Encryption
key size: 256
key provider: file
file location: something/encrypt_key.key with based64-encoded

Encrypt:
General setting: enabled
Encryption Method: Mcrypt AES (CBC mode)
Key Provider: Key module(It's the key I made from Key module)

--- update question --- Apr 14th 12:24pm
How the person decrypt the data when I sent the encrypted data to him/her?

  • 1
    It's encryption. They need to use the same libraries and have access to the secret keys. – tenken Apr 14 '16 at 16:29
2

You can call the decrypt() function as seen in _webform_encrypt_decrypt_nested_values:

/**
 * Helper function to recursively decrypt values in a webform structure.
 */
function _webform_encrypt_decrypt_nested_values(&$element, $key = '#default_value', $restrict = array()) {
  // Determine if we are checking access.
  $access = empty($restrict) ? TRUE : user_access('view encrypted values', $restrict['account']);

  // Loop through each item and decrypt the value.
  foreach (element_children($element) as $name) {
    $component = &$element[$name];
    if (!empty($component['#webform_component']['extra']['encrypt'])) {
      if (is_array($component[$key])) {
        foreach ($component[$key] as &$value) {
          $value = $access ? decrypt($value, array('base64' => TRUE)) : t('[Value Encrypted]');
        }
      }
      else {
        $component[$key] = $access ? decrypt($component[$key], array('base64' => TRUE)) : t('[Value Encrypted]');
      }
    }

    // Recurse if the current item has children.
    _webform_encrypt_decrypt_nested_values($component, $key, $restrict);
  }
}

So in your own code you want to call something like decrypt($value, array('base64' => TRUE)) where $value is (saved) encrypted webform submission data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.