Created
October 8, 2013 16:33
-
-
Save BillKeenan/6887459 to your computer and use it in GitHub Desktop.
symmetric encrypt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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