How to use the jsthemis.SecureCellContextImprint function in jsthemis

To help you get started, we’ve selected a few jsthemis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cossacklabs / themis / tools / js / jsthemis / scell_context_string_echo.js View on Github external
var jsthemis = require('jsthemis');

if (process.argv.length !== 6) {
    console.log('Usage:    ');
    process.exit(1);
}

var command = process.argv[2];
var key = new Buffer(process.argv[3]);
var message = process.argv[4];
var context = new Buffer(process.argv[5]);

if (command === "enc"){
    var message_buf = new Buffer(message);
    var encrypted = new jsthemis.SecureCellContextImprint(key);
    var result = encrypted.encrypt(message_buf, context);
    console.log(result.toString('base64'));
    process.exit(0)
} else if (command === 'dec'){
    var decrypter = new jsthemis.SecureCellContextImprint(key);
    var decoded_message = new Buffer(message, 'base64');
    var result = decrypter.decrypt(decoded_message, context);
    console.log(result.toString('ascii'));
    process.exit(0)
} else {
    console.log('Wrong command, use "enc" or "dec"');
    process.exit(1)
}
github cossacklabs / themis / tools / js / jsthemis / scell_context_string_echo.js View on Github external
process.exit(1);
}

var command = process.argv[2];
var key = new Buffer(process.argv[3]);
var message = process.argv[4];
var context = new Buffer(process.argv[5]);

if (command === "enc"){
    var message_buf = new Buffer(message);
    var encrypted = new jsthemis.SecureCellContextImprint(key);
    var result = encrypted.encrypt(message_buf, context);
    console.log(result.toString('base64'));
    process.exit(0)
} else if (command === 'dec'){
    var decrypter = new jsthemis.SecureCellContextImprint(key);
    var decoded_message = new Buffer(message, 'base64');
    var result = decrypter.decrypt(decoded_message, context);
    console.log(result.toString('ascii'));
    process.exit(0)
} else {
    console.log('Wrong command, use "enc" or "dec"');
    process.exit(1)
}

jsthemis

Themis is a convenient cryptographic library for data protection.

Apache-2.0
Latest version published 11 months ago

Package Health Score

74 / 100
Full package analysis