Built motion from commit 67e5df37.|2.0.66
[motion2.git] / server / components / encryptor / index.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x0b16=['createReadStream','createWriteStream','createCipher','algorithm','update','binary','write','end','final','close','unlink','decryptFile','crypto','bluebird','hasOwnProperty'];(function(_0x79c6de,_0x10de94){var _0x321a56=function(_0x2e313e){while(--_0x2e313e){_0x79c6de['push'](_0x79c6de['shift']());}};_0x321a56(++_0x10de94);}(_0x0b16,0x1b0));var _0x60b1=function(_0x7a68a5,_0x16f8b2){_0x7a68a5=_0x7a68a5-0x0;var _0x4ad428=_0x0b16[_0x7a68a5];return _0x4ad428;};'use strict';var crypto=require(_0x60b1('0x0'));var fs=require('fs');var BPromise=require(_0x60b1('0x1'));var defaultOptions={'algorithm':'aes192'};function combineOptions(_0x49f887){var _0x4a6397={};for(var _0x51e132 in defaultOptions){if(defaultOptions[_0x60b1('0x2')](_0x51e132)){_0x4a6397[_0x51e132]=defaultOptions[_0x51e132];}}if(_0x49f887){for(var _0x20c364 in _0x49f887){if(_0x49f887['hasOwnProperty'](_0x20c364)){_0x4a6397[_0x20c364]=_0x49f887[_0x20c364];}}}return _0x4a6397;}exports['encryptFile']=function(_0x500ff0,_0x92278a,_0x48e351,_0x17cec4){return new BPromise(function(_0x32c251,_0x566e33){_0x17cec4=combineOptions(_0x17cec4);var _0x4449d7=new Buffer(_0x48e351);var _0x55aceb=fs[_0x60b1('0x3')](_0x500ff0);var _0x3f8ef8=fs[_0x60b1('0x4')](_0x92278a);var _0x2ebece=crypto[_0x60b1('0x5')](_0x17cec4[_0x60b1('0x6')],_0x4449d7);_0x55aceb['on']('data',function(_0x320a7f){var _0x56d625=new Buffer(_0x2ebece[_0x60b1('0x7')](_0x320a7f),_0x60b1('0x8'));_0x3f8ef8[_0x60b1('0x9')](_0x56d625);});_0x55aceb['on'](_0x60b1('0xa'),function(){try{var _0x28ba7f=new Buffer(_0x2ebece[_0x60b1('0xb')](_0x60b1('0x8')),_0x60b1('0x8'));_0x3f8ef8[_0x60b1('0x9')](_0x28ba7f);_0x3f8ef8['end']();_0x3f8ef8['on'](_0x60b1('0xc'),function(){return _0x32c251(_0x92278a);});}catch(_0x4e047e){fs[_0x60b1('0xd')](_0x92278a);return _0x566e33(_0x4e047e);}});});};exports[_0x60b1('0xe')]=function(_0xc810fb,_0x6c2a7e,_0x3429fa,_0x3d5827){return new BPromise(function(_0xe716dc,_0x4b4213){_0x3d5827=combineOptions(_0x3d5827);var _0x349e98=new Buffer(_0x3429fa);var _0x518970=fs[_0x60b1('0x3')](_0xc810fb);var _0x3d5335=fs[_0x60b1('0x4')](_0x6c2a7e);var _0x579a3a=crypto['createDecipher'](_0x3d5827['algorithm'],_0x349e98);_0x518970['on']('data',function(_0x7466c0){var _0x4f62e7=new Buffer(_0x579a3a[_0x60b1('0x7')](_0x7466c0),'binary');_0x3d5335[_0x60b1('0x9')](_0x4f62e7);});_0x518970['on'](_0x60b1('0xa'),function(){try{var _0x5e417b=new Buffer(_0x579a3a[_0x60b1('0xb')](_0x60b1('0x8')),_0x60b1('0x8'));_0x3d5335[_0x60b1('0x9')](_0x5e417b);_0x3d5335[_0x60b1('0xa')]();_0x3d5335['on'](_0x60b1('0xc'),function(){return _0xe716dc(_0x6c2a7e);});}catch(_0x218708){fs[_0x60b1('0xd')](_0x6c2a7e);return _0x4b4213(_0x218708);}});});};