问题是这样的,小弟现在在做的是公众号对接工行的支付,其中有个数据加密的环节。我这个加密过去工行那边一直报解密失败。工行的加密要求为:API开放平台具体AES算法为AES/CBC/PKCS5Padding 针对AES算法 IV(initialization vector),即初始化向量长度为16字节(128位).初始化为0,加密后BASE64输出,解密向量与初始化向量是相同的。 下面是我个人构造的加密: aesCipher(data) { //const iv = new Buffer([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); //const iv = Buffer.alloc(16, 0) let aeskey = 'LjKqH69sLlqGe+pPSqgWUQ==' const iv = "0000000000000000" console.log(iv.length) var clearEncoding = 'utf8'; var cipherEncoding = 'base64'; var cipherChunks = []; var cipher = crypto.createCipheriv('aes-192-cbc', aeskey, iv); cipher.setAutoPadding(true); cipherChunks.push(cipher.update(data, clearEncoding, cipherEncoding)); cipherChunks.push(cipher.final(cipherEncoding)); return cipherChunks.join(''); }
想请大神来帮帮看看,这是我哪一步有问题。跪求啊,已经卡了好几天了。()