I have inherited a project and there is a .cert value which I am trying to reverse engineer to see how it was created. This value is created like so:
var rawCertValue = 'Q2VydGlmaWNhdGU6DQogICAgRG......'; // long value
var certificate = new Buffer(rawCertValue, 'base64').toString();
I have the original .pem key and can see that the certificate value in there matches the certificate
variable that is generated above. What I am trying to figure out is how they got the rawCertValue
I guess my question is what would be the reverse function for:
new Buffer(rawCertValue, 'base64').toString();
That new Buffer
variant is deprecated, you should use Buffer.from
instead which lets you specify the encoding. Also the toString
method takes an optional encoding, which defaults to utf8
. So your original code is equivalent to
var certificate = Buffer.from(rawCertValue, 'base64').toString('utf8');
The reverse operation for that would then be
var rawCertValue = Buffer.from(certificate, 'utf8').toString('base64');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With