'How to implement functions from PHP openssl_pkey_get_private, openssl_sign on NodeJS?
I write code according to the documentation, where the examples are shown in PHP
$data = json_encode([...]);
$key = openssl_pkey_get_private(
file_get_contents('./private.pem'),
file_get_contents('./password.txt')
);
openssl_sign($data, $sign, $key );
$signature = base64_encode($sign);
I am trying to do something in js.
const crypto = require('crypto');
const data = [];
const cert = '...'; // it's .pem file
const password = '...';
const signature = crypto.createSign('sha256');
const key = signature.sign({ key: cert, passphrase: password });
I'm not sure if this is correct, but I can't figure out how I can now execute the openssl_sign function.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|