Zaid
Zaid

Reputation: 79

How to generate Public Private key pairs for digital signatues in node.js?

Im developing an application in meteor.js. In this application a user "A" will send some data by signing it with its private key on to the server. So any other user "B" can verify it by decrypting the data with public key of "A". Now the problem is i dont know that how can I generate pub/priv key pairs for multiple user so that they can verify each other signatures.

Upvotes: 0

Views: 215

Answers (1)

Felix Fong
Felix Fong

Reputation: 985

By running the following command

-N means the RSA passphrase -C User's email address -f The location of the new RSA key pair

ssh-keygen -t dsa -N "" -C "[email protected]" -f ~/.ssh/random_id

const { exec } = require('child_process');
const randomId = '';
const userEmailAddress = ''
const baseLineCommand = `ssh-keygen -t dsa -N "" -C "${userEmailAddress}" -f ~/.ssh/${randomId}`;
exec(baseLineCommand, (err, stdout, stderr) => {
  if (err) {
    console.error(err);
    return;
  }
  // New RSA key key pair has been successfully generated
  console.log(stdout);
});

Upvotes: 1

Related Questions