Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
verboseOutput(util.inspect(encoded_message));
verboseOutput('\n');
/* JSON-encoded representation if not encrypted */
var encoded_json = copy(encoded_message);
if(isBuffer) {
encoded_json.data = data.toString('base64');
encoded_json.encoding = (encoding ? (encoding + '/') : '') + 'base64';
}
verboseOutput('Unencrypted JSON message format:');
verboseOutput(JSON.stringify(encoded_json));
verboseOutput('\n');
/* unencrypted format msgpack */
verboseOutput('Unencrypted msgpack message format:');
hexdump(msgpack.encode(encoded_message));
verboseOutput('\n');
/* plaintext without padding */
verboseOutput('Plaintext before encryption (without padding):');
var plaintext = data;
if(isString) {
plaintext = new Buffer(plaintext);
encoding = (encoding ? (encoding + '/') : '') + 'utf-8';
}
hexdump(plaintext);
verboseOutput('\n');
/* plaintext including padding */
verboseOutput('Plaintext before encryption (including padding):');
var paddedPlaintext = padPlaintext(plaintext);
hexdump(paddedPlaintext);
};
verboseOutput('Encrypted message format:');
verboseOutput(util.inspect(encrypted_message));
verboseOutput('\n');
/* encrypted format (JSON) */
var encrypted_json = copy(encrypted_message);
encrypted_json.data = encrypted_message.data.toString('base64');
encrypted_json.encoding = encrypted_message.encoding + '/base64'
verboseOutput('Encrypted JSON message format:');
verboseOutput(JSON.stringify(encrypted_json));
verboseOutput('\n');
/* encrypted format (msgpack)*/
verboseOutput('Encrypted msgpack message format:');
hexdump(msgpack.encode(encrypted_message));
verboseOutput('\n');
return {
encoded: encoded_json,
encrypted: encrypted_json
};
}