AES encryption in javascript and decrypting in java

后端 未结 3 1825
旧巷少年郎
旧巷少年郎 2020-12-10 10:20

I have an excisting webservice which encrypts and decrypts with AES, now i have to encrypt in the same way as java but in javascript. I have read all the topics about doing

3条回答
  •  误落风尘
    2020-12-10 10:28

    To decrypt hash generated using JAVA AES/ECB/PKCS5Padding, you need to create a decrypt cipher also with padding in js(nodejs).

    const crypto = require('crypto');
    function decrypt(data){
      var decipher = crypto.createCipheriv("aes-128-ecb", 'SAME_KEY_AS_JAVA', '');
      var dec = decipher.update(data,'base64','utf8');
      dec += decipher.final('utf8');
      return dec
    }
    

提交回复
热议问题