- Version: v8.11.3
- Platform: Linux x86_64
- Subsystem:
I'm trying to encrypt/decrypt data using a rsa key but the process fails somehow with this message :
Error: error:04099079:rsa routines:RSA_padding_check_PKCS1_OAEP_mgf1:oaep decoding error
Code :
varchildProcess=require('child_process');varcrypto=require('crypto');varpk;varmess_chiffre;varsign=function(){varbuf=newBuffer("Coucou c'est relou!!!");varsig=crypto.privateEncrypt(pk,buf);mess_chiffre=sig.toString('hex');console.log("Signed : ",mess_chiffre);};vardecrypt=function(){varbuff=newBuffer(mess_chiffre,'hex')console.log('Buffer : ',buff)console.log('decrypting withh pk: ')console.log(pk)varmess=crypto.privateDecrypt(pk,buff)console.log(mess)};childProcess.exec('openssl rsa -in private.key',{},function(err,stdout,stderr){if(err)throwerr;pk=stdout;// Save in memory for later usesign();decrypt();});
I'm trying to encrypt/decrypt data using a rsa key but the process fails somehow with this message :
Code :