Strapi Encryptable Field screenshot

Strapi Encryptable Field

Author Avatar Theme by Edwin luijten
Updated: 12 Aug 2025
15 Stars

Encrypts values on save, and decrypts on fetch.

Categories

Overview:

Strapi’s Encryptable Field Plugin is a plugin that allows users to encrypt and decrypt data in Strapi. It is important to note that this plugin should not be used to store user passwords, as hashing should be used for that purpose. The plugin supports the aes-256-cbc encryption method and is only compatible with Strapi version 4.

Features:

  • Encrypts data on create and update
  • Decrypts data on fetch one and many
  • Role-based decryption for selected roles
  • Basic settings for validation regex and input hint
  • Advanced settings for selectively showing decrypted values for roles

Installation:

  1. Open or create the file config/plugins.js
  2. Enable the plugin by adding the following snippet:
module.exports = ({ env }) => ({
  // ...
  settings: {
    encryption: {
      enabled: true,
      encryptionKey: env('ENCRYPTION_KEY'),
    },
  },
});
  1. Add the environment variable ENCRYPTION_KEY to your server and .env file
  2. Generate a key by running the following command in your terminal:
$ node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
  1. After installation and configuration, the custom field is ready to use. Add a new field and select “Encryptable” under the “Custom” tab.

Summary:

Strapi’s Encryptable Field Plugin is a useful plugin for encrypting and decrypting data in Strapi. It provides features such as role-based decryption, basic and advanced settings for customization, and easy installation and configuration. It is important to follow best practices and consult the rules around PII data when using this plugin in production.