Skip to content

Instantly share code, notes, and snippets.

@BillKeenan
Created October 8, 2013 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BillKeenan/6887459 to your computer and use it in GitHub Desktop.
Save BillKeenan/6887459 to your computer and use it in GitHub Desktop.
symmetric encrypt
function symmetricEncrypt(){
if (window.crypto.getRandomValues) {
require("/js/openpgp.min.js");
openpgp.init();
var key = openpgp_crypto_generateSessionKey(9);
$("#pubkey").append(key);
$("#pubkey").append("<br><Br>");
var crypt = openpgp_crypto_symmetricEncrypt(openpgp_crypto_getPrefixRandom(9), 9,key , $('#message').val(), false);
$("#pubkey").append(crypt);
} else {
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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment