mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2026-03-12 19:48:26 +00:00
update example
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
function encrypt() {
|
||||
if (window.crypto.getRandomValues) {
|
||||
require("./openpgp.min.js");
|
||||
|
||||
// read public key
|
||||
var pub_key = openpgp.key.readArmored($('#pubkey').text());
|
||||
$('#message').val(openpgp.encryptMessage(pub_key.keys,$('#message').val()));
|
||||
// sign and encrypt message
|
||||
var pgp_message = openpgp.encryptMessage(pub_key.keys, $('#message').val());
|
||||
|
||||
$('#message').val(pgp_message);
|
||||
window.alert("This message is going to be sent:\n" + $('#message').val());
|
||||
return true;
|
||||
} else {
|
||||
@@ -10,18 +14,4 @@ function encrypt() {
|
||||
window.alert("Error: Browser not supported\nReason: We need a cryptographically secure PRNG to be implemented (i.e. the window.crypto method)\nSolution: Use Chrome >= 11, Safari >= 3.1 or Firefox >= 21");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function require(script) {
|
||||
$.ajax({
|
||||
url: script,
|
||||
dataType: "script",
|
||||
async: false, // <-- this is the key
|
||||
success: function () {
|
||||
// all good...
|
||||
},
|
||||
error: function () {
|
||||
throw new Error("Could not load script " + script);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user