crypto/encrypting.js
// Creating a function to encrypt string
Creating a function to encrypt string
Creating a function to encrypt string
function encryptString(plaintext, privateKeyFile) {
  const privateKey = fs.readFileSync(privateKeyFile, 'utf8');
  const encrypted = crypto.publicEncrypt(
    {
      key: privateKey,
      passphrase: 'pass',
    },
    Buffer.from(plaintext),
  );
  return encrypted.toString('hex');
}
function encryptString ( plaintext , privateKeyFile ) { const privateKey = fs . readFileSync ( privateKeyFile , 'utf8' ) ; const encrypted = crypto . publicEncrypt ( { key : privateKey , passphrase : 'pass' , } , Buffer . from ( plaintext ) , ) ; return encrypted . toString ( 'hex' ) ; }
Creating a function to encrypt string
Creating a function to encrypt string
// privateEncrypt() method with its parameters