Built motion from commit (unavailable).|2.6.0
[motion2.git] / server / components / encryptor / index.js
index ce4a78b..f32010c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x50ff=['close','decryptFile','createReadStream','createDecipher','encryptString','secret','update','utf8','base64','decryptString','crypto','bluebird','lodash','../../config/logger','app','secrets','session','aes-256-ctr','aes192','encrypt','algorithm','join','error','is\x20not\x20a\x20supported\x20algorithm.\x20Your\x20system\x20supports\x20the\x20following\x20algorithms:','getCiphers','filter','indexOf','hasOwnProperty','createWriteStream','data','binary','write','end','final'];(function(_0x10ae5a,_0x3ffe94){var _0xd78aeb=function(_0x528c8c){while(--_0x528c8c){_0x10ae5a['push'](_0x10ae5a['shift']());}};_0xd78aeb(++_0x3ffe94);}(_0x50ff,0xd6));var _0xf50f=function(_0x58943c,_0x17dea4){_0x58943c=_0x58943c-0x0;var _0x5abf69=_0x50ff[_0x58943c];return _0x5abf69;};'use strict';var crypto=require(_0xf50f('0x0'));var fs=require('fs');var BPromise=require(_0xf50f('0x1'));var _=require(_0xf50f('0x2'));var config=require('../../config/environment');var logger=require(_0xf50f('0x3'))(_0xf50f('0x4'));const AES_SUPPORTED_RX=/^aes(-)?\d{3}(-(cbc|cfb|ctr)(1|8)?){0,1}$/;const stringOptions={'secret':config[_0xf50f('0x5')][_0xf50f('0x6')],'algorithm':_0xf50f('0x7')};const fileOptions={'algorithm':_0xf50f('0x8')};if(config[_0xf50f('0x9')]&&config[_0xf50f('0x9')][_0xf50f('0xa')]){var isSupported=isAlgorithmSupported(config['encrypt']['algorithm']);if(isSupported){fileOptions[_0xf50f('0xa')]=config['encrypt'][_0xf50f('0xa')];}else{var supportedAlgorithms=getSupportedCiphers()[_0xf50f('0xb')](',\x20');logger[_0xf50f('0xc')](config[_0xf50f('0x9')][_0xf50f('0xa')],_0xf50f('0xd'),supportedAlgorithms);}}function isASupportedCipher(_0x5af076){return AES_SUPPORTED_RX['test'](_0x5af076);}function getSupportedCiphers(){return crypto[_0xf50f('0xe')]()[_0xf50f('0xf')](isASupportedCipher);}function isAlgorithmSupported(_0x35271a){return getSupportedCiphers()[_0xf50f('0x10')](_0x35271a)>-0x1;}function combineOptions(_0xcb1471){var _0x427269={};for(var _0x579b09 in fileOptions){if(fileOptions[_0xf50f('0x11')](_0x579b09)){_0x427269[_0x579b09]=fileOptions[_0x579b09];}}if(_0xcb1471){for(var _0x55549e in _0xcb1471){if(_0xcb1471['hasOwnProperty'](_0x55549e)){_0x427269[_0x55549e]=_0xcb1471[_0x55549e];}}}return _0x427269;}exports['encryptFile']=function(_0x55fcee,_0x52306e,_0x1fe4ed,_0x34e213){return new BPromise(function(_0x23304f,_0x222323){_0x34e213=combineOptions(_0x34e213);var _0x24ba20=new Buffer(_0x1fe4ed);var _0x4b341d=fs['createReadStream'](_0x55fcee);var _0x437887=fs[_0xf50f('0x12')](_0x52306e);var _0x507099=crypto['createCipher'](_0x34e213[_0xf50f('0xa')],_0x24ba20);_0x4b341d['on'](_0xf50f('0x13'),function(_0x20c17b){var _0x5cfc9a=new Buffer(_0x507099['update'](_0x20c17b),_0xf50f('0x14'));_0x437887[_0xf50f('0x15')](_0x5cfc9a);});_0x4b341d['on'](_0xf50f('0x16'),function(){try{var _0x1e016d=new Buffer(_0x507099[_0xf50f('0x17')]('binary'),_0xf50f('0x14'));_0x437887[_0xf50f('0x15')](_0x1e016d);_0x437887[_0xf50f('0x16')]();_0x437887['on'](_0xf50f('0x18'),function(){return _0x23304f(_0x52306e);});}catch(_0x2a8fbd){fs['unlink'](_0x52306e);return _0x222323(_0x2a8fbd);}});});};exports[_0xf50f('0x19')]=function(_0x389c8d,_0x57862a,_0x23717f,_0x2f4551){return new BPromise(function(_0xafaaa9,_0x1fb074){_0x2f4551=combineOptions(_0x2f4551);var _0x174180=new Buffer(_0x23717f);var _0x305a6c=fs[_0xf50f('0x1a')](_0x389c8d);var _0x286314=fs[_0xf50f('0x12')](_0x57862a);var _0x59c3d1=crypto[_0xf50f('0x1b')](_0x2f4551['algorithm'],_0x174180);_0x305a6c['on'](_0xf50f('0x13'),function(_0x155ad5){var _0x752838=new Buffer(_0x59c3d1['update'](_0x155ad5),_0xf50f('0x14'));_0x286314[_0xf50f('0x15')](_0x752838);});_0x305a6c['on'](_0xf50f('0x16'),function(){try{var _0x34c403=new Buffer(_0x59c3d1['final'](_0xf50f('0x14')),_0xf50f('0x14'));_0x286314[_0xf50f('0x15')](_0x34c403);_0x286314['end']();_0x286314['on']('close',function(){return _0xafaaa9(_0x57862a);});}catch(_0x79efd6){fs['unlink'](_0x57862a);return _0x1fb074(_0x79efd6);}});});};exports[_0xf50f('0x1c')]=function(_0x516cde,_0x2f9332,_0x52ffa9){var _0x2a6a76=_0x52ffa9||stringOptions['algorithm'];var _0xe7fdb1=_0x2f9332||stringOptions[_0xf50f('0x1d')];var _0x512958=crypto['createCipher'](_0x2a6a76,_0xe7fdb1);var _0x35bdaa=_0x512958[_0xf50f('0x1e')](_0x516cde,_0xf50f('0x1f'),'base64');_0x35bdaa+=_0x512958[_0xf50f('0x17')](_0xf50f('0x20'));return _0x35bdaa;};exports[_0xf50f('0x21')]=function(_0x121d1f,_0x3ab2dc,_0x14fcf5){var _0x4607c9=_0x14fcf5||stringOptions[_0xf50f('0xa')];var _0x55a830=_0x3ab2dc||stringOptions[_0xf50f('0x1d')];var _0x318ab0=crypto[_0xf50f('0x1b')](_0x4607c9,_0x55a830);var _0x4df549=_0x318ab0['update'](_0x121d1f,'base64',_0xf50f('0x1f'));_0x4df549+=_0x318ab0[_0xf50f('0x17')](_0xf50f('0x1f'));return _0x4df549;};
\ No newline at end of file
+var _0x7040=['write','end','final','close','unlink','decryptFile','secret','utf8','decryptString','base64','crypto','lodash','../../config/environment','../../config/logger','app','secrets','session','aes-256-ctr','encrypt','algorithm','join','error','is\x20not\x20a\x20supported\x20algorithm.\x20Your\x20system\x20supports\x20the\x20following\x20algorithms:','test','filter','indexOf','hasOwnProperty','encryptFile','createReadStream','createWriteStream','data','update','binary'];(function(_0x246148,_0x1358ee){var _0x453d94=function(_0x59920e){while(--_0x59920e){_0x246148['push'](_0x246148['shift']());}};_0x453d94(++_0x1358ee);}(_0x7040,0xaf));var _0x0704=function(_0xc817d7,_0x5d6206){_0xc817d7=_0xc817d7-0x0;var _0x25cc06=_0x7040[_0xc817d7];return _0x25cc06;};'use strict';var crypto=require(_0x0704('0x0'));var fs=require('fs');var BPromise=require('bluebird');var _=require(_0x0704('0x1'));var config=require(_0x0704('0x2'));var logger=require(_0x0704('0x3'))(_0x0704('0x4'));const AES_SUPPORTED_RX=/^aes(-)?\d{3}(-(cbc|cfb|ctr)(1|8)?){0,1}$/;const stringOptions={'secret':config[_0x0704('0x5')][_0x0704('0x6')],'algorithm':_0x0704('0x7')};const fileOptions={'algorithm':'aes192'};if(config[_0x0704('0x8')]&&config['encrypt'][_0x0704('0x9')]){var isSupported=isAlgorithmSupported(config[_0x0704('0x8')]['algorithm']);if(isSupported){fileOptions[_0x0704('0x9')]=config['encrypt'][_0x0704('0x9')];}else{var supportedAlgorithms=getSupportedCiphers()[_0x0704('0xa')](',\x20');logger[_0x0704('0xb')](config[_0x0704('0x8')][_0x0704('0x9')],_0x0704('0xc'),supportedAlgorithms);}}function isASupportedCipher(_0x175cb7){return AES_SUPPORTED_RX[_0x0704('0xd')](_0x175cb7);}function getSupportedCiphers(){return crypto['getCiphers']()[_0x0704('0xe')](isASupportedCipher);}function isAlgorithmSupported(_0x33cd62){return getSupportedCiphers()[_0x0704('0xf')](_0x33cd62)>-0x1;}function combineOptions(_0x227a5a){var _0xbd3349={};for(var _0x165dae in fileOptions){if(fileOptions[_0x0704('0x10')](_0x165dae)){_0xbd3349[_0x165dae]=fileOptions[_0x165dae];}}if(_0x227a5a){for(var _0x40320b in _0x227a5a){if(_0x227a5a[_0x0704('0x10')](_0x40320b)){_0xbd3349[_0x40320b]=_0x227a5a[_0x40320b];}}}return _0xbd3349;}exports[_0x0704('0x11')]=function(_0x22bb4e,_0x41c222,_0x31b180,_0x3f8e22){return new BPromise(function(_0x47c6fc,_0x258f50){_0x3f8e22=combineOptions(_0x3f8e22);var _0x56fc9b=new Buffer(_0x31b180);var _0x4e7c5f=fs[_0x0704('0x12')](_0x22bb4e);var _0x1a0991=fs[_0x0704('0x13')](_0x41c222);var _0x394953=crypto['createCipher'](_0x3f8e22[_0x0704('0x9')],_0x56fc9b);_0x4e7c5f['on'](_0x0704('0x14'),function(_0x6955fc){var _0x5bad99=new Buffer(_0x394953[_0x0704('0x15')](_0x6955fc),_0x0704('0x16'));_0x1a0991[_0x0704('0x17')](_0x5bad99);});_0x4e7c5f['on'](_0x0704('0x18'),function(){try{var _0x318f54=new Buffer(_0x394953[_0x0704('0x19')](_0x0704('0x16')),_0x0704('0x16'));_0x1a0991[_0x0704('0x17')](_0x318f54);_0x1a0991[_0x0704('0x18')]();_0x1a0991['on'](_0x0704('0x1a'),function(){return _0x47c6fc(_0x41c222);});}catch(_0x1f94fa){fs[_0x0704('0x1b')](_0x41c222);return _0x258f50(_0x1f94fa);}});});};exports[_0x0704('0x1c')]=function(_0x3d5b1e,_0x19d19f,_0x35b6e7,_0xc245ba){return new BPromise(function(_0x54126a,_0x107bd7){_0xc245ba=combineOptions(_0xc245ba);var _0x21887d=new Buffer(_0x35b6e7);var _0x49f3eb=fs[_0x0704('0x12')](_0x3d5b1e);var _0x59ee70=fs[_0x0704('0x13')](_0x19d19f);var _0x23396d=crypto['createDecipher'](_0xc245ba[_0x0704('0x9')],_0x21887d);_0x49f3eb['on'](_0x0704('0x14'),function(_0x29dec8){var _0x113e22=new Buffer(_0x23396d[_0x0704('0x15')](_0x29dec8),_0x0704('0x16'));_0x59ee70[_0x0704('0x17')](_0x113e22);});_0x49f3eb['on'](_0x0704('0x18'),function(){try{var _0xa29efb=new Buffer(_0x23396d[_0x0704('0x19')](_0x0704('0x16')),_0x0704('0x16'));_0x59ee70[_0x0704('0x17')](_0xa29efb);_0x59ee70[_0x0704('0x18')]();_0x59ee70['on']('close',function(){return _0x54126a(_0x19d19f);});}catch(_0x8de505){fs[_0x0704('0x1b')](_0x19d19f);return _0x107bd7(_0x8de505);}});});};exports['encryptString']=function(_0xc8633,_0x4762ee,_0x4b0b8e){var _0x19d655=_0x4b0b8e||stringOptions[_0x0704('0x9')];var _0x3b3c43=_0x4762ee||stringOptions[_0x0704('0x1d')];var _0x237dd2=crypto['createCipher'](_0x19d655,_0x3b3c43);var _0x16e8a1=_0x237dd2[_0x0704('0x15')](_0xc8633,_0x0704('0x1e'),'base64');_0x16e8a1+=_0x237dd2[_0x0704('0x19')]('base64');return _0x16e8a1;};exports[_0x0704('0x1f')]=function(_0x83e70d,_0x244d15,_0x3a20d0){var _0x28a62a=_0x3a20d0||stringOptions['algorithm'];var _0x58bab9=_0x244d15||stringOptions[_0x0704('0x1d')];var _0x5b0877=crypto['createDecipher'](_0x28a62a,_0x58bab9);var _0x4e5a77=_0x5b0877[_0x0704('0x15')](_0x83e70d,_0x0704('0x20'),'utf8');_0x4e5a77+=_0x5b0877[_0x0704('0x19')]('utf8');return _0x4e5a77;};
\ No newline at end of file