Skip to content
Home » Documentation » Encryption for Contact Form 7

Encryption for Contact Form 7

Overview

Encryption for Contact Form 7 is a very simple plugin that extends the functionality of Contact Form 7. Protect your users’ data, increase privacy, and add an additional layer of security to all submitted form data through Contact Form 7 by encrypting them with this easy-to-use plugin!

The PRO version saves submitted form data and includes a backend view where privileged users can view the encrypted data. It introduced two (2) new user capabilities, read encrypted data and manage entries, where any user can be granted one or both while the rest either see redacted information or none at all.

What does it do?

This plugin works behind the scenes to keep your form data safe. When a user submits a form created in Contact Form 7, the data is encrypted. Without this plugin, storage plugins for Contact Form 7 save information in the database submitted through your forms in plain text. With this plugin, that data is encrypted before being saved.

Emails sent from Contact Form 7 aren’t affected either! The recipient(s) will see the decrypted data.

Why do I need it?

If your database is ever hacked or stolen, data stored in plain text are vulnerable! Encrypting those values adds a layer of security and privacy because the hacker won’t be able to read them, it will look like jumbled, garbled text. You may need this plugin if your WordPress website uses Contact Form 7 and:

How do I use it?

After installing and activating this plugin, you only need to add two (2) new lines to your WordPress website’s wp-config.php file:

define('ENCRYPT_CF7_SECRET_KEY', '<generated secret key>');
define('ENCRYPT_CF7_HASH_KEY', '<generated hash key>');

Both keys should be unique to your website, as they are the keys to your kingdom! Literally, these keys are what makes your encryption and decryption work for just your website.

If your database was stolen and they tried to decrypt the form data with this plugin, it will not work without your keys, keeping your form data safe!

If you lose your keys, you cannot decrypt your own data (and neither can I), so keep them safe. Consider backing them up somewhere offline too.

This is also why the keys are saved in the wp-config.php file instead of a setting in the plugin accessible from WordPress backend: because then it’d be in the very database you’re trying to keep safe! That’s like leaving your car keys in the car.

Additionally, there are two keys, so even if one is compromised, the data still can’t be decrypted. This is like two people having to turn both of their keys at the same time to open the secret vault.

About the Secret Key

The secret key defined by ENCRYPT_CF7_SECRET_KEY can be whatever you want! You can generate a random string, use something you’ll remember, or grab one from my random key generator. The longer and more random it is, the more challenging it’ll be to guess.

About the Hash Key

The hash key defined by ENCRYPT_CF7_HASH_KEY, by default, is a random string that is 64 bytes in length. You can generate your own using the code snippet below or grab one from my random key generator.

Random Key Generator

Want some random keys? Take these! Click here to refresh the page for new ones. These keys change every time the page is refreshed and they aren’t stored anywhere.

    Customize Encryption

    If you know what you’re doing, you can customize your encryption and decryption method with more constant variables. See the sections below.

    Cipher Algorithm

    You can specify a cipher algorithm by setting the constant value for ENCRYPT_CF7_CIPHER like this:

    define('ENCRYPT_CF7_CIPHER', '<insert algo here>');
    View possible cipher algorithms
    aes-128-cbc
    aes-128-cbc-hmac-sha1
    aes-128-cbc-hmac-sha256
    aes-128-ccm
    aes-128-cfb
    aes-128-cfb1
    aes-128-cfb8
    aes-128-ctr
    aes-128-gcm
    aes-128-ocb
    aes-128-ofb
    aes-128-xts
    aes-192-cbc
    aes-192-ccm
    aes-192-cfb
    aes-192-cfb1
    aes-192-cfb8
    aes-192-ctr
    aes-192-gcm
    aes-192-ocb
    aes-192-ofb
    aes-256-cbc
    aes-256-cbc-hmac-sha1
    aes-256-cbc-hmac-sha256
    aes-256-ccm
    aes-256-cfb
    aes-256-cfb1
    aes-256-cfb8
    aes-256-ctr
    aes-256-gcm
    aes-256-ocb
    aes-256-ofb
    aes-256-xts
    aria-128-cbc
    aria-128-ccm
    aria-128-cfb
    aria-128-cfb1
    aria-128-cfb8
    aria-128-ctr
    aria-128-gcm
    aria-128-ofb
    aria-192-cbc
    aria-192-ccm
    aria-192-cfb
    aria-192-cfb1
    aria-192-cfb8
    aria-192-ctr
    aria-192-gcm
    aria-192-ofb
    aria-256-cbc
    aria-256-ccm
    aria-256-cfb
    aria-256-cfb1
    aria-256-cfb8
    aria-256-ctr
    aria-256-gcm
    aria-256-ofb
    bf-cbc
    bf-cfb
    bf-ofb
    camellia-128-cbc
    camellia-128-cfb
    camellia-128-cfb1
    camellia-128-cfb8
    camellia-128-ctr
    camellia-128-ofb
    camellia-192-cbc
    camellia-192-cfb
    camellia-192-cfb1
    camellia-192-cfb8
    camellia-192-ctr
    camellia-192-ofb
    camellia-256-cbc
    camellia-256-cfb
    camellia-256-cfb1
    camellia-256-cfb8
    camellia-256-ctr
    camellia-256-ofb
    cast5-cbc
    cast5-cfb
    cast5-ofb
    chacha20
    chacha20-poly1305
    id-aes128-CCM
    id-aes128-GCM
    id-aes128-wrap
    id-aes128-wrap-pad
    id-aes192-CCM
    id-aes192-GCM
    id-aes192-wrap
    id-aes192-wrap-pad
    id-aes256-CCM
    id-aes256-GCM
    id-aes256-wrap
    id-aes256-wrap-pad
    idea-cbc
    idea-cfb
    idea-ofb
    seed-cbc
    seed-cfb
    seed-ofb
    sm4-cbc
    sm4-cfb
    sm4-ctr
    sm4-ofb

    Hash Algorithm

    You can specify a hash algorithm by setting the constant value for ENCRYPT_CF7_HASH_ALGO like this:

    define('ENCRYPT_CF7_HASH_ALGO', '<insert algo here>');
    View possible hash algorithms
    md2
    md4
    md5
    sha1
    sha224
    sha256
    sha384
    sha512/224
    sha512/256
    sha512
    sha3-224
    sha3-256
    sha3-384
    sha3-512
    ripemd128
    ripemd160
    ripemd256
    ripemd320
    whirlpool
    tiger128,3
    tiger160,3
    tiger192,3
    tiger128,4
    tiger160,4
    tiger192,4
    snefru
    snefru256
    gost
    gost-crypto
    haval128,3
    haval160,3
    haval192,3
    haval224,3
    haval256,3
    haval128,4
    haval160,4
    haval192,4
    haval224,4
    haval256,4
    haval128,5
    haval160,5
    haval192,5
    haval224,5
    haval256,5

    Related Post Module Attributes Before

    array(29) {
      ["post_type"]=>
      string(4) "post"
      ["post_id"]=>
      string(1) "0"
      ["exclude"]=>
      string(1) "0"
      ["title"]=>
      string(32) "Related Articles & Tutorials"
      ["description"]=>
      string(0) ""
      ["max"]=>
      string(1) "3"
      ["post_ids"]=>
      string(0) ""
      ["exclude_ids"]=>
      string(0) ""
      ["is_series"]=>
      string(0) ""
      ["featured_term"]=>
      string(2) "72"
      ["exclude_terms"]=>
      string(0) ""
      ["exclusive"]=>
      string(1) "1"
      ["order"]=>
      string(4) "DESC"
      ["show_image"]=>
      string(2) "on"
      ["image_size"]=>
      string(6) "medium"
      ["menu_order_label"]=>
      string(0) ""
      ["show_order_label"]=>
      string(2) "on"
      ["show_date"]=>
      string(2) "on"
      ["show_meta_keys"]=>
      string(2) "on"
      ["show_modified"]=>
      string(0) ""
      ["show_author"]=>
      string(0) ""
      ["show_categories"]=>
      string(0) ""
      ["show_primary_category"]=>
      string(0) ""
      ["show_description"]=>
      string(0) ""
      ["show_reading_time"]=>
      string(2) "on"
      ["show_cta"]=>
      string(2) "on"
      ["cta"]=>
      string(9) "Read more"
      ["autoplay"]=>
      string(0) ""
      ["allow_sticky"]=>
      string(0) ""
    }
    

    Related Post Module Attributes

    array(29) {
      ["post_type"]=>
      string(4) "post"
      ["post_id"]=>
      string(1) "0"
      ["exclude"]=>
      string(1) "0"
      ["title"]=>
      string(32) "Related Articles & Tutorials"
      ["description"]=>
      string(0) ""
      ["max"]=>
      string(1) "3"
      ["post_ids"]=>
      string(0) ""
      ["exclude_ids"]=>
      string(0) ""
      ["is_series"]=>
      string(0) ""
      ["featured_term"]=>
      string(2) "72"
      ["exclude_terms"]=>
      string(0) ""
      ["exclusive"]=>
      string(1) "1"
      ["order"]=>
      string(4) "DESC"
      ["show_image"]=>
      string(2) "on"
      ["image_size"]=>
      string(6) "medium"
      ["menu_order_label"]=>
      string(0) ""
      ["show_order_label"]=>
      string(2) "on"
      ["show_date"]=>
      string(2) "on"
      ["show_meta_keys"]=>
      string(2) "on"
      ["show_modified"]=>
      string(0) ""
      ["show_author"]=>
      string(0) ""
      ["show_categories"]=>
      string(0) ""
      ["show_primary_category"]=>
      string(0) ""
      ["show_description"]=>
      string(0) ""
      ["show_reading_time"]=>
      string(2) "on"
      ["show_cta"]=>
      string(2) "on"
      ["cta"]=>
      string(9) "Read more"
      ["autoplay"]=>
      string(0) ""
      ["allow_sticky"]=>
      string(0) ""
    }