Created
January 30, 2019 09:47
-
-
Save pladaria/c036ea6c04a62874f2594f841c3e7cae to your computer and use it in GitHub Desktop.
generate-vapid-keys created by pladaria - https://repl.it/@pladaria/generate-vapid-keys
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require('crypto'); | |
const urlBase64 = require('urlsafe-base64'); | |
function generateVAPIDKeys() { | |
const curve = crypto.createECDH('prime256v1'); | |
curve.generateKeys(); | |
return { | |
publicKey: urlBase64.encode(curve.getPublicKey()), | |
privateKey: urlBase64.encode(curve.getPrivateKey()) | |
}; | |
} | |
console.log(JSON.stringify(generateVAPIDKeys(), null, 2)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"requires": true, | |
"lockfileVersion": 1, | |
"dependencies": { | |
"urlsafe-base64": { | |
"version": "1.0.0", | |
"resolved": "https://registry.npmjs.org/urlsafe-base64/-/urlsafe-base64-1.0.0.tgz", | |
"integrity": "sha1-I/iQaabGL0bPOh07ABac77kL4MY=" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment