
Rename resources to dist. Eliminate keyring bundle and expose keyring class in openpgp module. Add mochaTest grunt task to run node server-side tests. Add node_pack grunt task to create npm package into dist and install it for testing. Add node_store config property which specifies location of localStorage emulation when using node. Add repository info to package.json. Move util.js to src directory from util since it is the only file there. Rename class properties in openpgp to the new class names.
29 lines
980 B
JavaScript
29 lines
980 B
JavaScript
function encrypt() {
|
|
if (window.crypto.getRandomValues) {
|
|
require("./openpgp.min.js");
|
|
openpgp.init();
|
|
var pub_key = openpgp.read_publicKey($('#pubkey').text());
|
|
$('#message').val(openpgp.write_encrypted_message(pub_key,$('#message').val()));
|
|
window.alert("This message is going to be sent:\n" + $('#message').val());
|
|
return true;
|
|
} else {
|
|
$("#mybutton").val("browser not supported");
|
|
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);
|
|
}
|
|
});
|
|
}
|