RSA-SHA Vascomm Module
npm install vascomm-rsa-sha bash
npm install vascomm-rsa-sha
`
Generating RSA KeyPair
To perform the following actions, you must have OpenSSL installed on your operating system.
1. Move to the directiories where you want to generate the RSA KeyPair.
2. Generating the Private Key
` bash
openssl genrsa -out privateKey.pem 2048
`
Notes: you can change privateKey.pem to the desired output name of generated Private Key.
3. Generating the Public Key
`bash
openssl rsa -pubout -in privateKey.pem -out publicKey.pem
`
Notes: privateKey.pem must be the Private Key filename. You can change publicKey.pem to the desired output name of generated Public Key.
Usage
` javascript
let RSA_SHA = require('RSA-SHA');
let fs = require('fs');
let publicKey = fs.readFileSync('/path/to/public/key');
let privateKey = fs.readFileSync('/path/to/private/key');
let text = "Lorem Ipsum"
// Encrypt RSA
let encypted = RSA_SHA.encryptRSA(text, publicKey);
console.log(encypted)
// Decrypt RSA
console.log(RSA_SHA.decryptRSA(encypted, privateKey));
// Sign SHA
let signed = RSA_SHA.signSHA(text, privateKey);
console.log(signed);
//Verify SHA
console.log(RSA_SHA.verifySHA(text,signed, publicKey)); //true
``