Built motion from commit c116dc8b.|2.6.30
[motion2.git] / server / components / encryptor / index.js
index fb4dcf3..e74e00e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x796e=['createReadStream','createWriteStream','createCipher','update','binary','write','end','final','close','unlink','createDecipher','data','secret','utf8','base64','decryptString','crypto','../../config/environment','../../config/logger','app','secrets','aes-256-ctr','aes192','encrypt','algorithm','join','error','is\x20not\x20a\x20supported\x20algorithm.\x20Your\x20system\x20supports\x20the\x20following\x20algorithms:','test','getCiphers','filter','hasOwnProperty','encryptFile'];(function(_0x3feb3f,_0x211c4){var _0x585ac8=function(_0x1b6999){while(--_0x1b6999){_0x3feb3f['push'](_0x3feb3f['shift']());}};_0x585ac8(++_0x211c4);}(_0x796e,0x1de));var _0xe796=function(_0x528d91,_0x36364e){_0x528d91=_0x528d91-0x0;var _0x26bd5a=_0x796e[_0x528d91];return _0x26bd5a;};'use strict';var crypto=require(_0xe796('0x0'));var fs=require('fs');var BPromise=require('bluebird');var _=require('lodash');var config=require(_0xe796('0x1'));var logger=require(_0xe796('0x2'))(_0xe796('0x3'));const AES_SUPPORTED_RX=/^aes(-)?\d{3}(-(cbc|cfb|ctr)(1|8)?){0,1}$/;const stringOptions={'secret':config[_0xe796('0x4')]['session'],'algorithm':_0xe796('0x5')};const fileOptions={'algorithm':_0xe796('0x6')};if(config['encrypt']&&config[_0xe796('0x7')][_0xe796('0x8')]){var isSupported=isAlgorithmSupported(config[_0xe796('0x7')][_0xe796('0x8')]);if(isSupported){fileOptions[_0xe796('0x8')]=config['encrypt'][_0xe796('0x8')];}else{var supportedAlgorithms=getSupportedCiphers()[_0xe796('0x9')](',\x20');logger[_0xe796('0xa')](config[_0xe796('0x7')][_0xe796('0x8')],_0xe796('0xb'),supportedAlgorithms);}}function isASupportedCipher(_0x772fb9){return AES_SUPPORTED_RX[_0xe796('0xc')](_0x772fb9);}function getSupportedCiphers(){return crypto[_0xe796('0xd')]()[_0xe796('0xe')](isASupportedCipher);}function isAlgorithmSupported(_0x5c02c9){return getSupportedCiphers()['indexOf'](_0x5c02c9)>-0x1;}function combineOptions(_0x2e9df3){var _0x12f8fa={};for(var _0x2cca5c in fileOptions){if(fileOptions[_0xe796('0xf')](_0x2cca5c)){_0x12f8fa[_0x2cca5c]=fileOptions[_0x2cca5c];}}if(_0x2e9df3){for(var _0x877967 in _0x2e9df3){if(_0x2e9df3['hasOwnProperty'](_0x877967)){_0x12f8fa[_0x877967]=_0x2e9df3[_0x877967];}}}return _0x12f8fa;}exports[_0xe796('0x10')]=function(_0x254bba,_0x57672e,_0x4aacf2,_0x5a7fb2){return new BPromise(function(_0x1b147c,_0xf1fbfc){_0x5a7fb2=combineOptions(_0x5a7fb2);var _0x3a27b3=new Buffer(_0x4aacf2);var _0x52b7e2=fs[_0xe796('0x11')](_0x254bba);var _0x158701=fs[_0xe796('0x12')](_0x57672e);var _0x5a83b3=crypto[_0xe796('0x13')](_0x5a7fb2['algorithm'],_0x3a27b3);_0x52b7e2['on']('data',function(_0x30587d){var _0x5eb412=new Buffer(_0x5a83b3[_0xe796('0x14')](_0x30587d),_0xe796('0x15'));_0x158701[_0xe796('0x16')](_0x5eb412);});_0x52b7e2['on'](_0xe796('0x17'),function(){try{var _0x1eff6d=new Buffer(_0x5a83b3[_0xe796('0x18')]('binary'),_0xe796('0x15'));_0x158701[_0xe796('0x16')](_0x1eff6d);_0x158701['end']();_0x158701['on'](_0xe796('0x19'),function(){return _0x1b147c(_0x57672e);});}catch(_0x499623){fs[_0xe796('0x1a')](_0x57672e);return _0xf1fbfc(_0x499623);}});});};exports['decryptFile']=function(_0x19685a,_0x3d5961,_0x4c1e24,_0xff8c61){return new BPromise(function(_0x39e3d8,_0x5b89f5){_0xff8c61=combineOptions(_0xff8c61);var _0x54dcf2=new Buffer(_0x4c1e24);var _0x373593=fs[_0xe796('0x11')](_0x19685a);var _0x36b7cf=fs[_0xe796('0x12')](_0x3d5961);var _0x263e69=crypto[_0xe796('0x1b')](_0xff8c61[_0xe796('0x8')],_0x54dcf2);_0x373593['on'](_0xe796('0x1c'),function(_0x252d0a){var _0x3fd386=new Buffer(_0x263e69[_0xe796('0x14')](_0x252d0a),_0xe796('0x15'));_0x36b7cf[_0xe796('0x16')](_0x3fd386);});_0x373593['on'](_0xe796('0x17'),function(){try{var _0x346c23=new Buffer(_0x263e69[_0xe796('0x18')](_0xe796('0x15')),_0xe796('0x15'));_0x36b7cf[_0xe796('0x16')](_0x346c23);_0x36b7cf[_0xe796('0x17')]();_0x36b7cf['on'](_0xe796('0x19'),function(){return _0x39e3d8(_0x3d5961);});}catch(_0x5326f6){fs[_0xe796('0x1a')](_0x3d5961);return _0x5b89f5(_0x5326f6);}});});};exports['encryptString']=function(_0x481a4d,_0x5c7fd8,_0x140e30){var _0x2c9590=_0x140e30||stringOptions[_0xe796('0x8')];var _0xf882e2=_0x5c7fd8||stringOptions[_0xe796('0x1d')];var _0x2e2e14=crypto[_0xe796('0x13')](_0x2c9590,_0xf882e2);var _0x2071d0=_0x2e2e14['update'](_0x481a4d,_0xe796('0x1e'),_0xe796('0x1f'));_0x2071d0+=_0x2e2e14[_0xe796('0x18')]('base64');return _0x2071d0;};exports[_0xe796('0x20')]=function(_0x566ed2,_0x4be475,_0x3d03d3){var _0x306eea=_0x3d03d3||stringOptions[_0xe796('0x8')];var _0x5c19da=_0x4be475||stringOptions[_0xe796('0x1d')];var _0x140121=crypto[_0xe796('0x1b')](_0x306eea,_0x5c19da);var _0x45a496=_0x140121[_0xe796('0x14')](_0x566ed2,_0xe796('0x1f'),_0xe796('0x1e'));_0x45a496+=_0x140121[_0xe796('0x18')](_0xe796('0x1e'));return _0x45a496;};
\ No newline at end of file
+var _0xadce=['createWriteStream','createCipher','update','binary','write','final','end','close','unlink','decryptFile','encryptString','secret','utf8','base64','decryptString','createDecipher','crypto','bluebird','lodash','../../config/environment','../../config/logger','app','session','aes-256-ctr','aes192','encrypt','algorithm','join','error','is\x20not\x20a\x20supported\x20algorithm.\x20Your\x20system\x20supports\x20the\x20following\x20algorithms:','test','getCiphers','filter','indexOf','hasOwnProperty','createReadStream'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xadce,0xa0));var _0xeadc=function(_0x4a747d,_0x3b747f){_0x4a747d=_0x4a747d-0x0;var _0x3a5b5c=_0xadce[_0x4a747d];return _0x3a5b5c;};'use strict';var crypto=require(_0xeadc('0x0'));var fs=require('fs');var BPromise=require(_0xeadc('0x1'));var _=require(_0xeadc('0x2'));var config=require(_0xeadc('0x3'));var logger=require(_0xeadc('0x4'))(_0xeadc('0x5'));const AES_SUPPORTED_RX=/^aes(-)?\d{3}(-(cbc|cfb|ctr)(1|8)?){0,1}$/;const stringOptions={'secret':config['secrets'][_0xeadc('0x6')],'algorithm':_0xeadc('0x7')};const fileOptions={'algorithm':_0xeadc('0x8')};if(config[_0xeadc('0x9')]&&config['encrypt'][_0xeadc('0xa')]){var isSupported=isAlgorithmSupported(config['encrypt'][_0xeadc('0xa')]);if(isSupported){fileOptions[_0xeadc('0xa')]=config['encrypt'][_0xeadc('0xa')];}else{var supportedAlgorithms=getSupportedCiphers()[_0xeadc('0xb')](',\x20');logger[_0xeadc('0xc')](config['encrypt'][_0xeadc('0xa')],_0xeadc('0xd'),supportedAlgorithms);}}function isASupportedCipher(_0x4ee55e){return AES_SUPPORTED_RX[_0xeadc('0xe')](_0x4ee55e);}function getSupportedCiphers(){return crypto[_0xeadc('0xf')]()[_0xeadc('0x10')](isASupportedCipher);}function isAlgorithmSupported(_0x1b9689){return getSupportedCiphers()[_0xeadc('0x11')](_0x1b9689)>-0x1;}function combineOptions(_0x5b7a11){var _0x7ebaa6={};for(var _0xb6bcb5 in fileOptions){if(fileOptions[_0xeadc('0x12')](_0xb6bcb5)){_0x7ebaa6[_0xb6bcb5]=fileOptions[_0xb6bcb5];}}if(_0x5b7a11){for(var _0x4b46cb in _0x5b7a11){if(_0x5b7a11[_0xeadc('0x12')](_0x4b46cb)){_0x7ebaa6[_0x4b46cb]=_0x5b7a11[_0x4b46cb];}}}return _0x7ebaa6;}exports['encryptFile']=function(_0x1c18e7,_0x391aa2,_0x5119ca,_0x249f5b){return new BPromise(function(_0x4b6148,_0x5decb3){_0x249f5b=combineOptions(_0x249f5b);var _0x284c12=new Buffer(_0x5119ca);var _0x82b630=fs[_0xeadc('0x13')](_0x1c18e7);var _0x53fbcf=fs[_0xeadc('0x14')](_0x391aa2);var _0x363fbe=crypto[_0xeadc('0x15')](_0x249f5b['algorithm'],_0x284c12);_0x82b630['on']('data',function(_0x379be3){var _0x49b347=new Buffer(_0x363fbe[_0xeadc('0x16')](_0x379be3),_0xeadc('0x17'));_0x53fbcf[_0xeadc('0x18')](_0x49b347);});_0x82b630['on']('end',function(){try{var _0x3f9100=new Buffer(_0x363fbe[_0xeadc('0x19')](_0xeadc('0x17')),'binary');_0x53fbcf[_0xeadc('0x18')](_0x3f9100);_0x53fbcf[_0xeadc('0x1a')]();_0x53fbcf['on'](_0xeadc('0x1b'),function(){return _0x4b6148(_0x391aa2);});}catch(_0x4eb1f2){fs[_0xeadc('0x1c')](_0x391aa2);return _0x5decb3(_0x4eb1f2);}});});};exports[_0xeadc('0x1d')]=function(_0x9a0e09,_0x4e7d11,_0x28098c,_0x1c131f){return new BPromise(function(_0x7ded63,_0x7edcf1){_0x1c131f=combineOptions(_0x1c131f);var _0x5a0f6e=new Buffer(_0x28098c);var _0x2095db=fs['createReadStream'](_0x9a0e09);var _0x1a45b5=fs['createWriteStream'](_0x4e7d11);var _0x368a3f=crypto['createDecipher'](_0x1c131f['algorithm'],_0x5a0f6e);_0x2095db['on']('data',function(_0x20477f){var _0x3976f7=new Buffer(_0x368a3f['update'](_0x20477f),'binary');_0x1a45b5[_0xeadc('0x18')](_0x3976f7);});_0x2095db['on']('end',function(){try{var _0x46cdb9=new Buffer(_0x368a3f[_0xeadc('0x19')]('binary'),_0xeadc('0x17'));_0x1a45b5[_0xeadc('0x18')](_0x46cdb9);_0x1a45b5[_0xeadc('0x1a')]();_0x1a45b5['on']('close',function(){return _0x7ded63(_0x4e7d11);});}catch(_0x3eca3b){fs[_0xeadc('0x1c')](_0x4e7d11);return _0x7edcf1(_0x3eca3b);}});});};exports[_0xeadc('0x1e')]=function(_0x287b22,_0x4838cb,_0x289161){var _0x2ccdfb=_0x289161||stringOptions['algorithm'];var _0x2b25cb=_0x4838cb||stringOptions[_0xeadc('0x1f')];var _0x4a3209=crypto[_0xeadc('0x15')](_0x2ccdfb,_0x2b25cb);var _0x3733b3=_0x4a3209[_0xeadc('0x16')](_0x287b22,_0xeadc('0x20'),_0xeadc('0x21'));_0x3733b3+=_0x4a3209[_0xeadc('0x19')](_0xeadc('0x21'));return _0x3733b3;};exports[_0xeadc('0x22')]=function(_0xa21c9f,_0x51db85,_0x585c59){var _0x1a4d38=_0x585c59||stringOptions['algorithm'];var _0x1cb200=_0x51db85||stringOptions[_0xeadc('0x1f')];var _0x5652c1=crypto[_0xeadc('0x23')](_0x1a4d38,_0x1cb200);var _0x21b6c9=_0x5652c1['update'](_0xa21c9f,_0xeadc('0x21'),_0xeadc('0x20'));_0x21b6c9+=_0x5652c1[_0xeadc('0x19')]('utf8');return _0x21b6c9;};
\ No newline at end of file