Skip to content

Instantly share code, notes, and snippets.

@lholmquist
Last active December 28, 2015 03:59
Show Gist options
  • Save lholmquist/7438924 to your computer and use it in GitHub Desktop.
Save lholmquist/7438924 to your computer and use it in GitHub Desktop.
/**
Encrypt data being saved or updated if applicable
@private
@augments base
*/
this.encrypt = function( data ) {
// IF encryption is true, do so cool stuff
// or if not, just return the data
if( crypto.agcrypto ) {
// should i also be doing cryptoOptions.key = crypto.agcrypto.deriveKey( cryptoOptions.key )
cryptoOptions.data = sjcl.codec.utf8String.toBits( JSON.stringify( data ) );
return {
id: data[ recordId ],
data: agcrypto.encrypt( cryptoOptions )
};
}
return data;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment