TurtleIO.prototype.cipher = function ( arg, encode, iv ) {
var cipher, crypted;
encode = ( encode !== false );
iv = iv || this.config.session.iv;
cipher = crypto[encode ? "createCipher" : "createDecipher"]( "aes-256-cbc", iv ),
crypted = encode ? cipher.update( arg, "utf8", "hex" ) : cipher.update( arg, "hex", "utf8" );
crypted += cipher.final( encode ? "hex" : "utf8" );
return crypted;
};
Method cipher
Creates a cipher from two input parameters
Parameters:
arg must be a String.
(String to encrypt)
encode must be a Boolean.
([Optional] Encrypt or decrypt
arg
usingiv
, default istrue
)iv must be a String.
([Optional] Initialization vector)
Returns a String
(Result of crypto operation)