https://augustpinch.com/qnd7d2fhd?key=ed5dbed8ecdd9af92e2b54e652945382
8
Saturday, April 19, 2025
DIGITAL SIGNATURE TOOL
Digital Signature Tool
*Installation*
```
bash
npm install crypto
```
*Code*
```
const crypto = require('crypto');
// Generate a private key
const { privateKey, publicKey } = crypto.generateKeyPairSync('rsa', {
modulusLength: 2048,
publicKeyEncoding: {
type: 'spki',
format: 'pem'
},
privateKeyEncoding: {
type: 'pkcs8',
format: 'pem',
cipher: 'aes-256-cbc',
passphrase: ''
}
});
// Message to sign
const message = "Hello, World!";
// Sign the message
const sign = crypto.createSign('RSA-SHA256');
sign.update(message);
sign.end();
const signature = sign.sign(privateKey, 'hex');
// Verify the signature
const verify = crypto.createVerify('RSA-SHA256');
verify.update(message);
verify.end();
const isValid = verify.verify(publicKey, signature, 'hex');
console.log("Signature:", signature);
console.log("Is signature valid?", isValid);
console.log("Public Key:");
console.log(publicKey);
console.log("Private Key:");
console.log(privateKey);
```
This code generates a private key, signs a message, and verifies the signature using the corresponding public key.
*Note:* This is a basic example and may not be suitable for production use without additional security measures. Always consult with a cryptography expert or follow established security guidelines when implementing digital signatures in a real-world application.
Subscribe to:
Post Comments (Atom)
WORD AND CHARACTER COUNTER TOOL
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="view...
-
Domain IP Checker Domain IP Checker Enter a domain name: Check IP
-
Fast.com Web View
-
Privacy Policy Generator Privacy Policy Generator Generate Privac...
No comments:
Post a Comment