How to generate AES/CBC/PKCS5Padding encrypted cipher in angular2+

I am working on a feature which require Aes encrypted (AES/CBC/PKCS5padding) cipher text to be sent from client to server which has JAVA in backend, please help how to write in Angular/Node code? i have try to write below code but getting different decrypt text, can someone please help ?

I've a encryption function on the server side JAVA as below :

public static String encrypt(String plainText, String encryptionKey)
String encryptedText = "";
KeyGenerator kgen = KeyGenerator.getInstance("AES");
SecretKey aesKey = kgen.generateKey();

Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
byte[] key = encryptionKey.getBytes("UTF-8");
SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
IvParameterSpec ivparameterspec = new IvParameterSpec(key);
cipher.init(1, secretKey, ivparameterspec);
byte[] cipherText = cipher.doFinal(plainText.getBytes("UTF8"));
Base64.Encoder encoder = Base64.getEncoder();
encryptedText = encoder.encodeToString(cipherText);
catch (Exception E)
System.out.println("*************\nEncrypt Exception : " + E.getMessage() + "\n" + "*************");
return "1";
return encryptedText;

Below are my My Node/Angular Code:

    export const encryptUsingAES128 = (data: string) => {
  if (process.env.AES_ENCRYPTION_KEY !== undefined) {
    const key = String(process.env.AES_ENCRYPTION_KEY);
    const encryptionKey = CryptoJS.enc.Utf8.parse(key);
    const iv = CryptoJS.enc.Utf8.parse(key);
    const encrypted = CryptoJS.AES.encrypt(
        keySize: 16,
        iv: iv,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7,
    return encrypted.toString();
  } else {
    log.error('Invalid AES_ENCRYPTION_KEY');
    throw new Error('Invalid AES_ENCRYPTION_KEY');
How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum