AES CBC encryption in Node.js, Java and C# (Cross Language Encryption)

Ashish Dhodare
1 min readJan 28, 2021

We need encryption for protection of our data while transmitting it from sender to client or vice versa. For better protection, we need to be sure that only sender and receiver can read that data.

What is AES and CBC?

There are many encryption algorithms are available using which data can be encrypted. One of such method is AES. The Advanced Encryption Standard (AES), also known by its original name Rijndael. It is one of the most secure and mature encryption method used widely in the world. AES, is a block cipher and CBC (Cipher Blocker Chaining) is an advanced form of block cipher encryption. With CBC mode encryption, each ciphertext block is dependent on all plaintext blocks processed up to that point. This adds an extra level of complexity to the encrypted data.

Key sizes: 128, 192 or 256 bits

Block sizes: 128 bits

Node.js

AES-256-CBC encryption decryption in node.js

Node.js Result:

29lLcnzVg2my1xwZTAYYL1kjkEgTSAhjpgAJplPf74I=
some data to encrypt

Java

Java Result:

29lLcnzVg2my1xwZTAYYL1kjkEgTSAhjpgAJplPf74I=
some data to encrypt

C#

C# Result:

29lLcnzVg2my1xwZTAYYL1kjkEgTSAhjpgAJplPf74I=
some data to encrypt

Summary:

Encryption and decryption depends on encryption type (AES-256-CBC), encryption key and iv (initialization vector) and not on programming language. That’s why, encrypted string from node.js can be decrypted in C#/java and vice versa provided encryption type, encryption key and iv should be same.

--

--