@kusnadi/dsa-js
v1.0.4
Published
Digital Signature Algorithm Node.js
Downloads
8
Maintainers
Readme
Digital Signature Algorithm (Node.js)
1. GENERATE DSA PARAM
openssl dsaparam -out dsaparam.pem 2048
2. GENERATE DSA PRIVATE KEY
Without Encrypted Private Key
openssl gendsa -out privatekey.pem dsaparam.pem
With Encrypted Private Key
openssl gendsa -aes256 -out privatekey.enc.pem dsaparam.pem
3. GENERATE DSA PUBLIC KEY
Without Encrypted Private Key
openssl dsa -in privatekey.pem -pubout -out publickey.pem
With Encrypted Private Key
openssl dsa -in privatekey.enc.pem -pubout -out publickey.enc.pem
4. HOW TO USE THIS PACKAGE
const DSA = require('@kusnadi/dsa-js');
const dsa = new DSA("sha256");
// Load Private And Public Key
// if Private Key not encrypted, leave blank the second param of loadPrivateKey
dsa.loadPrivateKey("./privatekey.enc.pem", "admin123");
dsa.loadPublicKey("./publickey.enc.pem");
let message = "hallo";
// Create Signture
let signature = dsa.createSignature(message);
// Check Signature
let isVerfified = dsa.verify(message, signature);
console.log(message, signature, isVerfified);