Built motion from commit (unavailable).|2.5.25
[motion2.git] / server / components / encryptor / index.js
index dc2c03f..3253b6e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6050=['createReadStream','createDecipher','encryptString','secret','base64','utf8','crypto','bluebird','../../config/environment','secrets','session','aes-256-ctr','encryptFile','createWriteStream','createCipher','algorithm','data','update','binary','write','end','final','close','unlink','decryptFile'];(function(_0x512243,_0x515f84){var _0x2f5cae=function(_0x11e21a){while(--_0x11e21a){_0x512243['push'](_0x512243['shift']());}};_0x2f5cae(++_0x515f84);}(_0x6050,0x196));var _0x0605=function(_0x586507,_0x3d698a){_0x586507=_0x586507-0x0;var _0x17049f=_0x6050[_0x586507];return _0x17049f;};'use strict';var crypto=require(_0x0605('0x0'));var fs=require('fs');var BPromise=require(_0x0605('0x1'));var config=require(_0x0605('0x2'));const stringOptions={'secret':config[_0x0605('0x3')][_0x0605('0x4')],'algorithm':_0x0605('0x5')};const fileOptions={'algorithm':'aes192'};function combineOptions(_0x22d595){var _0x4576f4={};for(var _0x43403d in fileOptions){if(fileOptions['hasOwnProperty'](_0x43403d)){_0x4576f4[_0x43403d]=fileOptions[_0x43403d];}}if(_0x22d595){for(var _0x533b6d in _0x22d595){if(_0x22d595['hasOwnProperty'](_0x533b6d)){_0x4576f4[_0x533b6d]=_0x22d595[_0x533b6d];}}}return _0x4576f4;}exports[_0x0605('0x6')]=function(_0x578623,_0x58f7d2,_0x5660ad,_0x1629bf){return new BPromise(function(_0x11b8b5,_0xa08eca){_0x1629bf=combineOptions(_0x1629bf);var _0x5bb96=new Buffer(_0x5660ad);var _0x44fdd3=fs['createReadStream'](_0x578623);var _0x1882e6=fs[_0x0605('0x7')](_0x58f7d2);var _0xe54b22=crypto[_0x0605('0x8')](_0x1629bf[_0x0605('0x9')],_0x5bb96);_0x44fdd3['on'](_0x0605('0xa'),function(_0x4385d3){var _0x4af103=new Buffer(_0xe54b22[_0x0605('0xb')](_0x4385d3),_0x0605('0xc'));_0x1882e6[_0x0605('0xd')](_0x4af103);});_0x44fdd3['on'](_0x0605('0xe'),function(){try{var _0x34c9e6=new Buffer(_0xe54b22[_0x0605('0xf')](_0x0605('0xc')),_0x0605('0xc'));_0x1882e6[_0x0605('0xd')](_0x34c9e6);_0x1882e6[_0x0605('0xe')]();_0x1882e6['on'](_0x0605('0x10'),function(){return _0x11b8b5(_0x58f7d2);});}catch(_0x5b08ba){fs[_0x0605('0x11')](_0x58f7d2);return _0xa08eca(_0x5b08ba);}});});};exports[_0x0605('0x12')]=function(_0x4993ab,_0x5ce56a,_0x4eefe9,_0x12a455){return new BPromise(function(_0xd0996d,_0xa83443){_0x12a455=combineOptions(_0x12a455);var _0x2d46ef=new Buffer(_0x4eefe9);var _0xefc557=fs[_0x0605('0x13')](_0x4993ab);var _0x2b7b5a=fs[_0x0605('0x7')](_0x5ce56a);var _0x193520=crypto[_0x0605('0x14')](_0x12a455[_0x0605('0x9')],_0x2d46ef);_0xefc557['on'](_0x0605('0xa'),function(_0x2e2204){var _0x103952=new Buffer(_0x193520['update'](_0x2e2204),_0x0605('0xc'));_0x2b7b5a[_0x0605('0xd')](_0x103952);});_0xefc557['on'](_0x0605('0xe'),function(){try{var _0x443326=new Buffer(_0x193520[_0x0605('0xf')](_0x0605('0xc')),_0x0605('0xc'));_0x2b7b5a[_0x0605('0xd')](_0x443326);_0x2b7b5a[_0x0605('0xe')]();_0x2b7b5a['on']('close',function(){return _0xd0996d(_0x5ce56a);});}catch(_0xc334b8){fs['unlink'](_0x5ce56a);return _0xa83443(_0xc334b8);}});});};exports[_0x0605('0x15')]=function(_0x118e9c,_0x110098,_0xf182c4){var _0x10c575=_0xf182c4||stringOptions[_0x0605('0x9')];var _0x2ea61d=_0x110098||stringOptions[_0x0605('0x16')];var _0x234231=crypto[_0x0605('0x8')](_0x10c575,_0x2ea61d);var _0x9f2833=_0x234231[_0x0605('0xb')](_0x118e9c,'utf8',_0x0605('0x17'));_0x9f2833+=_0x234231[_0x0605('0xf')]('base64');return _0x9f2833;};exports['decryptString']=function(_0x55ebd8,_0x33558f,_0x226825){var _0x4163cd=_0x226825||stringOptions[_0x0605('0x9')];var _0x1cee1d=_0x33558f||stringOptions[_0x0605('0x16')];var _0x4e32ef=crypto[_0x0605('0x14')](_0x4163cd,_0x1cee1d);var _0x5daef6=_0x4e32ef[_0x0605('0xb')](_0x55ebd8,_0x0605('0x17'),_0x0605('0x18'));_0x5daef6+=_0x4e32ef[_0x0605('0xf')](_0x0605('0x18'));return _0x5daef6;};
\ No newline at end of file
+var _0xd399=['secrets','session','aes-256-ctr','aes192','encrypt','algorithm','join','test','filter','indexOf','hasOwnProperty','createWriteStream','update','binary','final','write','end','close','decryptFile','createReadStream','createDecipher','data','encryptString','secret','createCipher','base64','decryptString','crypto','bluebird','lodash','../../config/environment','../../config/logger','app'];(function(_0x4fa0e8,_0x26b636){var _0x19cadd=function(_0x4cda62){while(--_0x4cda62){_0x4fa0e8['push'](_0x4fa0e8['shift']());}};_0x19cadd(++_0x26b636);}(_0xd399,0x1a7));var _0x9d39=function(_0x5e6682,_0x2c8139){_0x5e6682=_0x5e6682-0x0;var _0x5f3810=_0xd399[_0x5e6682];return _0x5f3810;};'use strict';var crypto=require(_0x9d39('0x0'));var fs=require('fs');var BPromise=require(_0x9d39('0x1'));var _=require(_0x9d39('0x2'));var config=require(_0x9d39('0x3'));var logger=require(_0x9d39('0x4'))(_0x9d39('0x5'));const AES_SUPPORTED_RX=/^aes(-)?\d{3}(-(cbc|cfb|ctr)(1|8)?){0,1}$/;const stringOptions={'secret':config[_0x9d39('0x6')][_0x9d39('0x7')],'algorithm':_0x9d39('0x8')};const fileOptions={'algorithm':_0x9d39('0x9')};if(config[_0x9d39('0xa')]&&config['encrypt'][_0x9d39('0xb')]){var isSupported=isAlgorithmSupported(config['encrypt'][_0x9d39('0xb')]);if(isSupported){fileOptions[_0x9d39('0xb')]=config[_0x9d39('0xa')][_0x9d39('0xb')];}else{var supportedAlgorithms=getSupportedCiphers()[_0x9d39('0xc')](',\x20');logger['error'](config[_0x9d39('0xa')][_0x9d39('0xb')],'is\x20not\x20a\x20supported\x20algorithm.\x20Your\x20system\x20supports\x20the\x20following\x20algorithms:',supportedAlgorithms);}}function isASupportedCipher(_0x27e2ed){return AES_SUPPORTED_RX[_0x9d39('0xd')](_0x27e2ed);}function getSupportedCiphers(){return crypto['getCiphers']()[_0x9d39('0xe')](isASupportedCipher);}function isAlgorithmSupported(_0x557a8e){return getSupportedCiphers()[_0x9d39('0xf')](_0x557a8e)>-0x1;}function combineOptions(_0xc36308){var _0x1e1538={};for(var _0x3a1ce1 in fileOptions){if(fileOptions[_0x9d39('0x10')](_0x3a1ce1)){_0x1e1538[_0x3a1ce1]=fileOptions[_0x3a1ce1];}}if(_0xc36308){for(var _0x9143d0 in _0xc36308){if(_0xc36308['hasOwnProperty'](_0x9143d0)){_0x1e1538[_0x9143d0]=_0xc36308[_0x9143d0];}}}return _0x1e1538;}exports['encryptFile']=function(_0x157237,_0x489dc0,_0x230873,_0x20ba9e){return new BPromise(function(_0x407182,_0x5e4e38){_0x20ba9e=combineOptions(_0x20ba9e);var _0x4bd38c=new Buffer(_0x230873);var _0x5bdeed=fs['createReadStream'](_0x157237);var _0x405b14=fs[_0x9d39('0x11')](_0x489dc0);var _0x41d643=crypto['createCipher'](_0x20ba9e[_0x9d39('0xb')],_0x4bd38c);_0x5bdeed['on']('data',function(_0x4e8a45){var _0x5bc650=new Buffer(_0x41d643[_0x9d39('0x12')](_0x4e8a45),_0x9d39('0x13'));_0x405b14['write'](_0x5bc650);});_0x5bdeed['on']('end',function(){try{var _0xc730c2=new Buffer(_0x41d643[_0x9d39('0x14')](_0x9d39('0x13')),'binary');_0x405b14[_0x9d39('0x15')](_0xc730c2);_0x405b14[_0x9d39('0x16')]();_0x405b14['on'](_0x9d39('0x17'),function(){return _0x407182(_0x489dc0);});}catch(_0x5b226e){fs['unlink'](_0x489dc0);return _0x5e4e38(_0x5b226e);}});});};exports[_0x9d39('0x18')]=function(_0x5d261f,_0x10fcd0,_0x9b5940,_0x1b0895){return new BPromise(function(_0x5d2698,_0x36c1d2){_0x1b0895=combineOptions(_0x1b0895);var _0x2cc3de=new Buffer(_0x9b5940);var _0x3604d7=fs[_0x9d39('0x19')](_0x5d261f);var _0x387f0e=fs[_0x9d39('0x11')](_0x10fcd0);var _0x8d5cec=crypto[_0x9d39('0x1a')](_0x1b0895['algorithm'],_0x2cc3de);_0x3604d7['on'](_0x9d39('0x1b'),function(_0x99fd60){var _0x586793=new Buffer(_0x8d5cec[_0x9d39('0x12')](_0x99fd60),_0x9d39('0x13'));_0x387f0e[_0x9d39('0x15')](_0x586793);});_0x3604d7['on'](_0x9d39('0x16'),function(){try{var _0xa3d27c=new Buffer(_0x8d5cec[_0x9d39('0x14')](_0x9d39('0x13')),_0x9d39('0x13'));_0x387f0e['write'](_0xa3d27c);_0x387f0e[_0x9d39('0x16')]();_0x387f0e['on'](_0x9d39('0x17'),function(){return _0x5d2698(_0x10fcd0);});}catch(_0x14c4e4){fs['unlink'](_0x10fcd0);return _0x36c1d2(_0x14c4e4);}});});};exports[_0x9d39('0x1c')]=function(_0x5af85d,_0x302e09,_0x39f52c){var _0x54238c=_0x39f52c||stringOptions['algorithm'];var _0x3851b5=_0x302e09||stringOptions[_0x9d39('0x1d')];var _0x8e494c=crypto[_0x9d39('0x1e')](_0x54238c,_0x3851b5);var _0x3d3e4e=_0x8e494c[_0x9d39('0x12')](_0x5af85d,'utf8','base64');_0x3d3e4e+=_0x8e494c[_0x9d39('0x14')](_0x9d39('0x1f'));return _0x3d3e4e;};exports[_0x9d39('0x20')]=function(_0x332edc,_0xb4eb9c,_0x1501a9){var _0x218599=_0x1501a9||stringOptions['algorithm'];var _0x1e1c2c=_0xb4eb9c||stringOptions[_0x9d39('0x1d')];var _0x4edefe=crypto[_0x9d39('0x1a')](_0x218599,_0x1e1c2c);var _0x49af3c=_0x4edefe['update'](_0x332edc,'base64','utf8');_0x49af3c+=_0x4edefe[_0x9d39('0x14')]('utf8');return _0x49af3c;};
\ No newline at end of file