Skip to content

Commit

Permalink
Update main.js
Browse files Browse the repository at this point in the history
  • Loading branch information
TheChiefMeat authored Feb 25, 2018
1 parent dcd8a97 commit aa1d35a
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,44 @@ $(document).ready(function() {

$('[data-toggle="popover"]').popover({placement: 'top'});

// SIGN
var signButton = $("#sign-button");

signButton.click(function(){
var signPlainText = $("#sign-plain-text");
var SignedText = $("#signed-text");
var signPrivateKey = $("#sign-private-key");
var signPassphrase = $("#sign-passphrase");

var currUser = kbpgp.KeyManager.import_from_armored_pgp({
armored: signPrivateKey.val()
}, function(err, currUser) {
if (!err) {
if (currUser.is_pgp_locked()) {
currUser.unlock_pgp({
passphrase: signPassphrase.val()
}, function(err) {
if (!err) {
console.log("Loaded private key with passphrase");

var params = {
msg: signPlainText.val(),
sign_with: currUser
};

kbpgp.box(params, function(err, result_string, result_buffer) {
console.log(err, result_string, result_buffer);
SignedText.val(result_string);
});
}
});
} else {
console.log("Loaded private key w/o passphrase");
}
}
});
});

/* New code by Matej Ramuta */

// ENCRYPTION
Expand Down Expand Up @@ -114,4 +152,4 @@ $(document).ready(function() {
}
});
});
});
});

0 comments on commit aa1d35a

Please sign in to comment.