const crypto = require('crypto');

function encrypt(buffer, password){
  var cipher = crypto.createCipher("aes-256-ctr", new Buffer(password));
  var crypted = Buffer.concat([cipher.update(buffer),cipher.final()]);
  return crypted;
}
 
function decrypt(buffer, password){
  var decipher = crypto.createDecipher("aes-256-ctr", new Buffer(password));

  var dec = Buffer.concat([decipher.update(buffer) , decipher.final()]);
  return dec;
}

exports.encrypt = encrypt;
exports.decrypt = decrypt;