Hi.
I'm trying to sign a string with SHA256 using a Private Key in PEM format, but I keep getting a different output than expected.
My goal is to produce the same output as
cat fileWithStringToSign.txt | openssl dgst -sha256 -sign $PEMFILE | openssl enc -base64 -A
My code is as follows:
var stringToSign = "blah blah";
var pem = '-----BEGIN PRIVATE KEY----- MIIEvQIB...';
var privateKey = forge.pki.privateKeyFromPem(pem);
var md = forge.md.sha256.create();
md.update(string); //I also tried md.update(string, 'utf8')
var signature = privateKey.sign(md);
return forge.util.encode64(signature);
Any help would be highly appreciated.
Hi.
I'm trying to sign a string with SHA256 using a Private Key in PEM format, but I keep getting a different output than expected.
My goal is to produce the same output as
cat fileWithStringToSign.txt | openssl dgst -sha256 -sign $PEMFILE | openssl enc -base64 -AMy code is as follows:
Any help would be highly appreciated.