Skip to content

Passing different encodings to Cipheriv updates results in ERR_INTERNAL_ASSERTION #64689

Description

@stickynotememo

Version

v26.4.0

Platform

Linux archbtw 7.1.3-arch2-2 #1 SMP PREEMPT_DYNAMIC Thu, 16 Jul 2026 17:41:28 +0000 x86_64 GNU/Linux

Subsystem

Crypto

What steps will reproduce the bug?

let key = scryptSync('hello', 'salt', 24)
let init_vector = randomFillSync(new Uint8Array(16))
const cipher = createCipheriv('aes-192-cbc', key, init_vector);

let encrypted = cipher.update('some clear text data', 'utf8', 'hex');
encrypted += cipher.final('utf8');

What is the expected behavior? Why is that the expected behavior?

The error should be handled gracefully and reported to the user.

What do you see instead?

Uncaught Error [ERR_INTERNAL_ASSERTION]: Cannot change encoding
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
    at assert.fail (node:internal/assert:17:9)
    at getDecoder (node:internal/crypto/cipher:101:12)
    at Cipheriv.final (node:internal/crypto/cipher:175:21) {
  code: 'ERR_INTERNAL_ASSERTION'

Metadata

Metadata

Assignees

No one assigned

    Labels

    cryptoIssues and PRs related to the crypto subsystem.errorsIssues and PRs related to JavaScript errors originated in Node.js core.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions