oversightstudio

encrypted fields

by oversightstudio
payload-plugins
Custom fields
v3
^3.90.0
MIT

Overview

Summary generated from the README

Provides an encryptedField function that wraps common Payload field types and encrypts their values at rest using AES-256-CTR with a random IV and the PAYLOAD_SECRET. Hooks encrypt and decrypt automatically, so the admin panel and API work as with normal fields. Values are JSON stringified before encryption and parsed back to keep their data type. Encrypted fields cannot be sorted or filtered in the database.

Features

  • encryptedField helper that wraps standard field definitions
  • Supports text, number, select, checkbox, email, date, json, textarea, code and radio fields
  • Handles hasMany select and number fields
  • Automatic encryption and decryption through field hooks
  • AES-256-CTR encryption keyed from PAYLOAD_SECRET with a random IV

Use cases

  • Protect sensitive personal data such as names or birth dates stored in a collection
  • Store confidential JSON or notes so they are unreadable in a raw database dump

From the author

Database field encryption for Payload.

Installation

npm i @oversightstudio/encrypted-fields

84

Stars

9

Forks

2

Open Issues

1 months ago

Last Updated

82

Weekly Downloads

v1.0.0

npm Version

9.9 KB

Unpacked Size

0

Dependencies

Repository stars

84+3 since Sep 7

Show data
Repository stars by day (UTC)
DateStars
Dec 6, 202684
Dec 5, 202684
Dec 4, 202684
Dec 3, 202684
Dec 2, 202684
Dec 1, 202684
Nov 30, 202684
Nov 29, 202684
Nov 28, 202684
Nov 27, 202684
Nov 26, 202684
Nov 25, 202684
Nov 24, 202684
Nov 23, 202684
Nov 22, 202684
Nov 21, 202684
Nov 20, 202684
Nov 19, 202684
Nov 18, 202684
Nov 17, 202684
Nov 16, 202684
Nov 15, 202684
Nov 14, 202684
Nov 13, 202684
Nov 12, 202684
Nov 11, 202684
Nov 10, 202684
Nov 9, 202684
Nov 8, 202684
Nov 7, 202684
Nov 6, 202684
Nov 5, 202684
Nov 4, 202684
Nov 3, 202683
Nov 2, 202683
Nov 1, 202683
Oct 31, 202683
Oct 30, 202683
Oct 29, 202683
Oct 28, 202683
Oct 27, 202683
Oct 26, 202683
Oct 25, 202683
Oct 24, 202683
Oct 23, 202683
Oct 22, 202683
Oct 21, 202683
Oct 20, 202683
Oct 19, 202683
Oct 18, 202683
Oct 17, 202683
Oct 16, 202683
Oct 15, 202683
Oct 14, 202683
Oct 13, 202683
Oct 12, 202683
Oct 11, 202683
Oct 10, 202683
Oct 9, 202682
Oct 8, 202682
Oct 7, 202682
Oct 6, 202682
Oct 5, 202682
Oct 4, 202682
Oct 3, 202682
Oct 2, 202682
Oct 1, 202682
Sep 30, 202681
Sep 29, 202681
Sep 28, 202681
Sep 27, 202681
Sep 26, 202681
Sep 25, 202681
Sep 24, 202681
Sep 23, 202681
Sep 22, 202681
Sep 21, 202681
Sep 20, 202681
Sep 19, 202681
Sep 18, 202681
Sep 17, 202681
Sep 16, 202681
Sep 15, 202681
Sep 14, 202681
Sep 13, 202681
Sep 12, 202681
Sep 11, 202681
Sep 10, 202681
Sep 9, 202681
Sep 8, 202681
Sep 7, 202681

Shared by 3 plugins in oversightstudio/payload-plugins.

npm weekly downloads

82+13 since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 202682
Dec 5, 202677
Dec 4, 202657
Dec 3, 202689
Dec 2, 202696
Dec 1, 2026107
Nov 30, 2026104
Nov 29, 2026108
Nov 28, 2026117
Nov 27, 2026137
Nov 26, 2026103
Nov 25, 2026101
Nov 24, 2026100
Nov 23, 2026112
Nov 22, 2026107
Nov 21, 202699
Nov 20, 202676
Nov 19, 202677
Nov 18, 202691
Nov 17, 202682
Nov 16, 202675
Nov 15, 202690
Nov 14, 202691
Nov 13, 2026111
Nov 12, 2026107
Nov 11, 2026111
Nov 10, 2026107
Nov 9, 2026106
Nov 8, 202688
Nov 7, 202691
Nov 6, 202678
Nov 5, 202685
Nov 4, 202666
Nov 3, 202694
Nov 2, 2026113
Nov 1, 2026133
Oct 31, 2026126
Oct 30, 2026156
Oct 29, 2026143
Oct 28, 2026131
Oct 27, 2026107
Oct 26, 202695
Oct 25, 202678
Oct 24, 202680
Oct 23, 202638
Oct 22, 202662
Oct 21, 2026101
Oct 20, 2026141
Oct 19, 2026141
Oct 18, 2026141
Oct 17, 2026169
Oct 16, 2026202
Oct 15, 2026187
Oct 14, 2026153
Oct 13, 2026110
Oct 12, 202698
Oct 11, 202698
Oct 10, 202668
Oct 9, 202647
Oct 8, 202647
Oct 7, 202649
Oct 6, 202648
Oct 5, 202649
Oct 4, 202650
Oct 3, 202651
Oct 2, 202647
Oct 1, 202645
Sep 30, 202651
Sep 29, 202649
Sep 28, 202651
Sep 27, 202650
Sep 26, 202653
Sep 25, 202648
Sep 24, 202644
Sep 23, 202639
Sep 22, 202641
Sep 21, 202640
Sep 20, 202643
Sep 19, 202640
Sep 18, 202650
Sep 17, 202651
Sep 16, 202649
Sep 15, 202653
Sep 14, 202661
Sep 13, 202661
Sep 12, 202666
Sep 11, 202664
Sep 10, 202667
Sep 9, 202672
Sep 8, 202676
Sep 7, 202669

Each point is npm's rolling 7-day download count.

Health Score

65/100Good

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/932147916-encrypted-fields.svg)](https://payloaddirectory.dev/plugins/932147916-encrypted-fields)
HTML
<a href="https://payloaddirectory.dev/plugins/932147916-encrypted-fields"><img src="https://payloaddirectory.dev/badge/932147916-encrypted-fields.svg" alt="Payload Directory"></a>
Updated Oct 23, 2026Created Feb 13, 2025Published Mar 2, 2025

README

Payload Encrypted Fields

Install

pnpm add @oversightstudio/encrypted-fields @payloadcms/ui

About

This package brings encrypted fields to Payload. It provides an encryptedField function that allows you to easily add encrypted fields to your collections.

It supports most field field types, including ones like select or number with hasMany enabled. Additionally, it fully integrates with Payload’s field customization options and lifecycle events, making it behave just like any other field—just encrypted.

The package automatically encrypts and decrypts field values using hooks, meaning you don’t need any extra setup to use encrypted fields in the admin panel or through the API.

Encryption

This package uses AES-256-CTR encryption, combined with your PAYLOAD_SECRET and a random IV. The encrypted value is stored as a string in the database.

For a deeper dive into how this encryption works, check out this blog post by Payload. It explains the same encryption approach but for a simple text field. This package expands on that to support more field types and make integration seamless.

Since encryption fundamentally converts data into an unreadable format, this package JSON stringifies your data before encrypting it and automatically parses it back after decryption to retain it's original data type.

Tradeofs

Using field encryption comes with some tradeoffs:

  • Larger data size – Encrypted values take up more space than raw values.
  • No sorting or filtering – Since the data is encrypted at rest, the database cannot sort or filter it.
  • Performance overhead – Encrypting and decrypting data adds some processing time.

These tradeoffs are standard when working with encrypted data, but they’re well worth it if protecting sensitive information is your goal.

Usage

Important: Make sure the PAYLOAD_SECRET environment variable is set before using this package.

import { CollectionConfig } from 'payload'
import { encryptedField } from '@oversightstudio/encrypted-fields'

export const SensitiveDataCollection: CollectionConfig = {
  slug: 'sensitive-data',
  fields: [
    encryptedField({
      name: 'name',
      type: 'text',
    }),
    encryptedField({
      name: 'age',
      type: 'number',
    }),
    encryptedField({
      name: 'birthDate',
      type: 'date',
    }),
    encryptedField({
      name: 'traits',
      type: 'select',
      options: [
        { label: 'Awesome', value: 'awesome' },
        { label: 'Based', value: 'based' },
        { label: 'Goat', value: 'goat' },
      ],
      hasMany: true,
    }),
  ],
}

Supported Field Types

Field TypeSupported
text✅ Yes
number✅ Yes
select✅ Yes
checkbox✅ Yes
email✅ Yes
date✅ Yes
json✅ Yes
textarea✅ Yes
code✅ Yes
radio✅ Yes
point❌ Not yet supported
richText❌ Not yet supported

All other missing field types (like as ui, tabs, etc.) are of course not supported, as they do not store user data that needs encryption.

Credits

  • Shoutout to Paul for being a real one.

Similar plugins