Transparent field-level encryption at rest for Prisma using AES-256-GCM. v1.6.0 requires @prisma/client >= 4.7. Encrypts specified fields automatically via Prisma middleware. Configuration is per-field with a master key. Different from alternatives like prisma-encryption-middleware by supporting key rotation, detecting encrypted fields via schema comments, and being actively maintained. Ships TypeScript types.
npm install prisma-field-encryptionNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to configure PrismaFieldEncryption middleware to encrypt a field named 'secret' on User model using AES-256-GCM.
Change to import { PrismaFieldEncryption } from 'prisma-field-encryption'.Generate a 32-byte key using openssl rand -hex 32 and set it as environment variable.
Do not attempt to query with encrypted fields; consider storing a searchable hash separately if needed.
Always call prisma.$use() immediately after creating the PrismaClient instance, before any operations.
Upgrade @prisma/client to >=4.7.
Set FIELD_ENCRYPTION_KEY=$(openssl rand -hex 32) and ensure it is exactly 64 hex characters.
Use import { PrismaFieldEncryption } from 'prisma-field-encryption' (ESM only).Ensure you have prisma-field-encryption@^1.0.0 installed. The config subpath was added in v1.0.0.