Update : I finally managed to recreate the whole Java code as required for the third party service. I must add that some of the libraries used are deprecated but I cannot do anything because that is what the other side is using and I must comply.
Java Code
SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(),
"AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(1, secretKeySpec);
byte[] aBytes = cipher.doFinal(inputString.getBytes());
Input Key : xxxxxxxxyyyyyyyy
Input Text: maryhadalittlelamb
Output : Z22GETg3Anl92%2BoyqdVWs9haQveaZxkDn8sQYP08iCY%3D
node.js Code
var cipher = crypto.createCipher('aes-128-ecb', key);
var encryptedPassword = cipher.update(text, 'utf8', 'base64');
encryptedPassword += cipher.final('base64');
console.log(encryptedPassword);
Input Key : xxxxxxxxyyyyyyyy
Input Text: maryhadalittlelamb
Output: mnqrpA2eqAhmseTrkBtH3YSGMoFs+ECPUamVd8/bgAQ=
The output for same inputstring and key is different for both. In fact the node.js is different but the base64 one looks identical nevertheless.
I am fairly new to these things therefore I have lost my may.
SecretKeySpecoutputs. if you give each aes core the same key bytes and choose the same key size and mode, they should be compatible. aside: ecb is a weak mode, use something better if possible.SecretKeySpec;Stringis not a container for binary data. This is wrong:String doc2 = new String(aBytes, "UTF-8");createCipherivinstead ofcreateCipher. That's the main point in the linked duplicate answer.