数据输入的值使用AES-128机制进行编码,其中前16个字符是我的应用程序的client_secret,它是解码过程的关键。我试图对其进行解码,但无法正常工作。 我试过的代码 `
const express=require('express');
const bodyParser=require('body-parser');
var app=express();
var crypto=require('crypto');
app.use(express.static(__dirname+'/public'));
app.use(bodyParser.urlencoded({extended:true}));
app.post('/',(req,res)=>{
var app_secret_key="my secret key";
var abc=JSON.stringify(req.body.data);
var key_app_secret_key=app_secret_key.substring(0,16);
function decrypt(key,data){
var decipher = crypto.createDecipher('aes-128-cbc',key);
var decrypted = decipher.update(data,'binary', 'utf8');
decrypted += decipher.final('utf8');
return decrypted;
}
console.log(decrypt(key_app_secret_key,abc));
});
app.listen(3000,()=>{
console.log('Server running in port 3000');
})
` 我在下面附加的错误。请告诉我如何解决此问题。提前致谢。
Error: error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length
at Decipher.final (crypto.js:183:26)
at decrypt (c:\xampp\htdocs\cameacoins\encryptPract\app.js:18:25)
at app.post (c:\xampp\htdocs\cameacoins\encryptPract\app.js:22:14)
at Layer.handle [as handle_request] (c:\xampp\htdocs\cameacoins\node_modules\express\lib\router\layer.js:95:5)
at next (c:\xampp\htdocs\cameacoins\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (c:\xampp\htdocs\cameacoins\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (c:\xampp\htdocs\cameacoins\node_modules\express\lib\router\layer.js:95:5)
at c:\xampp\htdocs\cameacoins\node_modules\express\lib\router\index.js:281:22
at Function.process_params (c:\xampp\htdocs\cameacoins\node_modules\express\lib\router\index.js:335:12)
at next (c:\xampp\htdocs\cameacoins\node_modules\express\lib\router\index.js:275:10)