Skip to content

crypto.createCipheriv is not implemented yet! #4568

Open
@rawand-faraidun

Description

@rawand-faraidun

I am trying to encrypt a value, and it works locally, but on Cloudflare Pages functions, i get this error:

[unenv] crypto.createCipheriv is not implemented yet!

These are my configs and implementation:

// package.json

{
  "name": "test-worker",
  "description": "test-worker",
  "version": "0.0.0",
  "private": true,
  ...
  "devDependencies": {
    "@cloudflare/workers-types": "^4.20250715.0",
    "@types/node": "^24.0.13",
    "typescript": "^5.8.3",
    "wrangler": "^4.24.3",
    ...
  },
  ...
}
// wrangler.jsonc

{
  "$schema": "./node_modules/wrangler/config-schema.json",
  "name": "test-worker",
  "compatibility_date": "2025-04-01",
  "pages_build_output_dir": "./assets",
  "compatibility_flags": ["nodejs_compat"],
  "observability": {
    "enabled": true
  }
}
// typescript implementation

import { createCipheriv, randomBytes } from 'node:crypto'

...

const iv = randomBytes(12)
const key = Buffer.from(env.AES_KEY, 'utf8')
const cipher = createCipheriv('aes-256-gcm', key, iv)
const encrypt = Buffer.concat([cipher.update(value, 'utf-8'), cipher.final()])
const authTag = cipher.getAuthTag()
const encrypted = Buffer.concat([iv, authTag, encrypt]).toString('base64')

...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions