added browser check
This commit is contained in:
parent
eb5e1b99cb
commit
4a00c3b7a7
|
@ -1,6 +1,7 @@
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
<title>Example | OpenPGP.js</title>
|
<title>Example | OpenPGP.js</title>
|
||||||
<link rel="stylesheet" media="all" href="example.css">
|
<link rel="stylesheet" media="all" href="example.css">
|
||||||
</head>
|
</head>
|
||||||
|
@ -65,7 +66,6 @@ z8jl9UymAkoTcsVWRVr5PKR0zsCxaNV3w5hv6j12+US7mEWe2kuD
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
<script src="./jquery.min.js" type="text/javascript" charset="utf-8"></script>
|
<script src="./jquery.min.js" type="text/javascript" charset="utf-8"></script>
|
||||||
<script src="./openpgp.min.js" type="text/javascript" charset="utf-8"></script>
|
|
||||||
<script src="./example.js" type="text/javascript" charset="utf-8"></script>
|
<script src="./example.js" type="text/javascript" charset="utf-8"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,6 +1,28 @@
|
||||||
function encrypt() {
|
function encrypt() {
|
||||||
openpgp.init();
|
if (window.crypto.getRandomValues) {
|
||||||
var pub_key = openpgp.read_publicKey($('#pubkey').text());
|
require("./openpgp.min.js");
|
||||||
$('#message').val(openpgp.write_encrypted_message(pub_key,$('#message').val()));
|
openpgp.init();
|
||||||
window.alert("This message is going to be sent:\n" + $('#message').val());
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user