· 8 years ago · Jan 03, 2018, 09:08 AM
1const crypto = require('crypto')
2
3const appKey = 'videoJJappkey'
4const secretKey = '1234567890123456'
5const iv = '1234567890123456'
6const encrypted = 'ogXFkaiRObOlHm4gsz4ICr/lXliITKy8/tY7sW/BTNzDzSP5UbmFFRP30rynd7LrTDjHFJgFBP0COFtH4Q2Bz9/eqFPNKMhnjx3aAhrTXt1Wo/th8SsAWgvOI58PmQfLGufYodSFofL2TWFht+sZrn9DZYcVAR8lkQcLIyk95bc='
7
8function decryption(data, key, iv) {
9 var clearEncoding = 'utf8';
10 var cipherEncoding = 'base64';
11 var cipherChunks = [];
12 var decipher = crypto.createDecipheriv('aes-128-cbc', key, iv);
13 decipher.setAutoPadding(true);
14 cipherChunks.push(decipher.update(data, cipherEncoding, clearEncoding));
15 cipherChunks.push(decipher.final(clearEncoding));
16 return cipherChunks.join('');
17}
18
19console.log(decryption(encrypted, secretKey, iv))