Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8989185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:11:38+00:00 2026-06-15T22:11:38+00:00

I want to encrypt some data in Node.js using an authenticated encryption scheme like

  • 0

I want to encrypt some data in Node.js using an authenticated encryption scheme like AES-GCM.

If I run the following sample code

app.get("/test", function(req,res)  {
  var key = "12345678901234567890123456789012";
  var iv = "123456789012"; 
  var cipher = crypto.createCipheriv("id-aes256-GCM",key.toString("binary"),iv.toString("binary"));
  var decipher = crypto.createDecipheriv("id-aes256-GCM",key.toString("binary"),iv.toString("binary"));

  console.log(decipher.update(cipher.update("bla")));
  console.log(decipher.update(cipher.final()));
  console.log(decipher.final());
});

I don’t get a console output but the error message “TypeError: DecipherFinal fail”.
If I use cipher AES-256-CTR instead of “id-aes256-GCM”, this code works fine and prints “bla” on the console.

What am I doing wrong?

edit:

Further investigating shows, that cipher.update(“bla”) returns “â” (single character…strange) and cipher.final() returns an empty string. I think this can’t be a correct ciphertext which should at least have the size of the plaintext…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:11:39+00:00Added an answer on June 15, 2026 at 10:11 pm

    GCM mode in OpenSSL works fine. It has been tested with other implementations as well. I know for a fact that the PolarSSL SSL library has its own GCM implementation for AES and PolarSSL can work fine with OpenSSL in return.

    The GCM mode of encryption for AES requires specific GCM-related parameters. The current NodeJS API cannot provide these values to OpenSSL. And as such the calls fail, but not with clean errors. (This is more of an OpenSSL issue than a NodeJS issue).

    (StevenLoomen points the reason out in the comments as well, but I’d like an answer for everybody to see)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to encrypt some server data using .NET's RSACryptoServiceProvider and decrypt it when
I want to encrypt some data in a form using jQuery before it's sent
I'm looking to encrypt some data using multiple ciphers (ie, AES, Serpent, Twofish...), and
I use the following code to encrypt some data and I want to move
I want to encrypt some data in python with PyCrypto. However I get an
I want to encrypt some Core Data columns with the NSValueTransformer class but I'm
I'm trying to use PHP and OpenSSL to encrypt some data using a public
I am looking to encrypt data. I want to generate encryption keys based on
I've written some abstractions for Crypto.Cipher.AES.encrypt/decrypt , and I want to write unit tests
I am now using Oracle 10g (10.0.2) I want to encrypt some columns in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.