Skip to content

Instantly share code, notes, and snippets.

@lholmquist
Created November 11, 2013 19:52
Show Gist options
  • Save lholmquist/7419273 to your computer and use it in GitHub Desktop.
Save lholmquist/7419273 to your computer and use it in GitHub Desktop.
test( "Encrypt/Decrypt raw bytes providing password", function() {
var agCrypto = AeroGear.Crypto(), //Need to create a "Crypto" object to re-use
rawPassword = agCrypto.deriveKey( PASSWORD ),
utf8String = sjcl.codec.utf8String,
hex = sjcl.codec.hex,
cipherText,
options = {
AAD: hex.toBits( BOB_AAD ),
key: rawPassword,
data: utf8String.toBits( PLAIN_TEXT )
};
cipherText = agCrypto.encrypt( options );
options.data = cipherText;
plainText = agCrypto.decrypt ( options );
equal( utf8String.fromBits( plainText ), PLAIN_TEXT, "Encryption has failed" );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment