Last active
January 11, 2023 15:44
-
-
Save ajinabraham/746d3bceb26b8aff9be4d871da61fb9f to your computer and use it in GitHub Desktop.
Revisions
-
ajinabraham revised this gist
May 14, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -16,4 +16,4 @@ const signature = signer.sign(private_key) const buff = new Buffer(signature); const base64data = buff.toString('base64'); console.log('Digital Signature: ' + base64data); //Equivalent to openssl dgst -sha256 -sign digital_sign/privateKey.pem webpackage.zip | base64 -
ajinabraham created this gist
May 14, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ //Create Private Key with OpenSSL //openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:4096 -pkeyopt rsa_keygen_pubexp:3 -out privateKey.pem //Generate Public Key to be used at the client side (Mobile) //openssl pkey -in privateKey.pem -out publicKey.pem -pubout const crypto = require('crypto') const fs = require('fs') const private_key = fs.readFileSync('digital_sign/privateKey.pem', 'utf-8') //File to be signed const package = fs.readFileSync('webpackage.zip') //Signing const signer = crypto.createSign('sha256'); signer.update(package); signer.end(); const signature = signer.sign(private_key) const buff = new Buffer(signature); const base64data = buff.toString('base64'); console.log('Digital Signature: ' + base64data); //Equvalent to openssl dgst -sha256 -sign digital_sign/privateKey.pem webpackage.zip | base64