Built motion from commit b0a9a629.|2.6.33
[motion2.git] / server / components / encryptor / index.js
index d357624..a5a6a4c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xba9e=['close','unlink','createDecipher','final','encryptString','secret','utf8','base64','decryptString','crypto','lodash','../../config/environment','../../config/logger','app','secrets','session','aes-256-ctr','aes192','encrypt','algorithm','join','error','is\x20not\x20a\x20supported\x20algorithm.\x20Your\x20system\x20supports\x20the\x20following\x20algorithms:','filter','indexOf','encryptFile','createReadStream','createWriteStream','createCipher','data','update','binary','end','write'];(function(_0x2c7618,_0x26be9c){var _0x5ce3f0=function(_0x1837b3){while(--_0x1837b3){_0x2c7618['push'](_0x2c7618['shift']());}};_0x5ce3f0(++_0x26be9c);}(_0xba9e,0x13b));var _0xeba9=function(_0x57314c,_0x16941d){_0x57314c=_0x57314c-0x0;var _0x281e89=_0xba9e[_0x57314c];return _0x281e89;};'use strict';var crypto=require(_0xeba9('0x0'));var fs=require('fs');var BPromise=require('bluebird');var _=require(_0xeba9('0x1'));var config=require(_0xeba9('0x2'));var logger=require(_0xeba9('0x3'))(_0xeba9('0x4'));const AES_SUPPORTED_RX=/^aes(-)?\d{3}(-(cbc|cfb|ctr)(1|8)?){0,1}$/;const stringOptions={'secret':config[_0xeba9('0x5')][_0xeba9('0x6')],'algorithm':_0xeba9('0x7')};const fileOptions={'algorithm':_0xeba9('0x8')};if(config[_0xeba9('0x9')]&&config[_0xeba9('0x9')][_0xeba9('0xa')]){var isSupported=isAlgorithmSupported(config['encrypt'][_0xeba9('0xa')]);if(isSupported){fileOptions[_0xeba9('0xa')]=config['encrypt'][_0xeba9('0xa')];}else{var supportedAlgorithms=getSupportedCiphers()[_0xeba9('0xb')](',\x20');logger[_0xeba9('0xc')](config['encrypt'][_0xeba9('0xa')],_0xeba9('0xd'),supportedAlgorithms);}}function isASupportedCipher(_0x18e4e0){return AES_SUPPORTED_RX['test'](_0x18e4e0);}function getSupportedCiphers(){return crypto['getCiphers']()[_0xeba9('0xe')](isASupportedCipher);}function isAlgorithmSupported(_0x5e75d2){return getSupportedCiphers()[_0xeba9('0xf')](_0x5e75d2)>-0x1;}function combineOptions(_0x3f37f3){var _0x198d6d={};for(var _0x2fd7c5 in fileOptions){if(fileOptions['hasOwnProperty'](_0x2fd7c5)){_0x198d6d[_0x2fd7c5]=fileOptions[_0x2fd7c5];}}if(_0x3f37f3){for(var _0x6e98f9 in _0x3f37f3){if(_0x3f37f3['hasOwnProperty'](_0x6e98f9)){_0x198d6d[_0x6e98f9]=_0x3f37f3[_0x6e98f9];}}}return _0x198d6d;}exports[_0xeba9('0x10')]=function(_0x3b50c8,_0x171b94,_0x2ed79f,_0x37edc4){return new BPromise(function(_0x2f8446,_0x3f8598){_0x37edc4=combineOptions(_0x37edc4);var _0x54503d=new Buffer(_0x2ed79f);var _0x13e6f6=fs[_0xeba9('0x11')](_0x3b50c8);var _0x573b2b=fs[_0xeba9('0x12')](_0x171b94);var _0x30babc=crypto[_0xeba9('0x13')](_0x37edc4['algorithm'],_0x54503d);_0x13e6f6['on'](_0xeba9('0x14'),function(_0x6c0c05){var _0x5f472d=new Buffer(_0x30babc[_0xeba9('0x15')](_0x6c0c05),_0xeba9('0x16'));_0x573b2b['write'](_0x5f472d);});_0x13e6f6['on'](_0xeba9('0x17'),function(){try{var _0x83b115=new Buffer(_0x30babc['final'](_0xeba9('0x16')),_0xeba9('0x16'));_0x573b2b[_0xeba9('0x18')](_0x83b115);_0x573b2b[_0xeba9('0x17')]();_0x573b2b['on'](_0xeba9('0x19'),function(){return _0x2f8446(_0x171b94);});}catch(_0x198114){fs[_0xeba9('0x1a')](_0x171b94);return _0x3f8598(_0x198114);}});});};exports['decryptFile']=function(_0x3a8a0a,_0x4ded60,_0x374d81,_0x2d38c6){return new BPromise(function(_0x31457e,_0x32a0c3){_0x2d38c6=combineOptions(_0x2d38c6);var _0x2b9546=new Buffer(_0x374d81);var _0x4c8305=fs[_0xeba9('0x11')](_0x3a8a0a);var _0x5787f0=fs[_0xeba9('0x12')](_0x4ded60);var _0x2a7186=crypto[_0xeba9('0x1b')](_0x2d38c6[_0xeba9('0xa')],_0x2b9546);_0x4c8305['on']('data',function(_0x256199){var _0x2400ce=new Buffer(_0x2a7186[_0xeba9('0x15')](_0x256199),'binary');_0x5787f0[_0xeba9('0x18')](_0x2400ce);});_0x4c8305['on'](_0xeba9('0x17'),function(){try{var _0x51f012=new Buffer(_0x2a7186[_0xeba9('0x1c')](_0xeba9('0x16')),_0xeba9('0x16'));_0x5787f0[_0xeba9('0x18')](_0x51f012);_0x5787f0['end']();_0x5787f0['on'](_0xeba9('0x19'),function(){return _0x31457e(_0x4ded60);});}catch(_0x5ebe52){fs[_0xeba9('0x1a')](_0x4ded60);return _0x32a0c3(_0x5ebe52);}});});};exports[_0xeba9('0x1d')]=function(_0x4de610,_0x51a37b,_0x42cd44){var _0x475174=_0x42cd44||stringOptions['algorithm'];var _0x3c04e5=_0x51a37b||stringOptions[_0xeba9('0x1e')];var _0x5277c8=crypto[_0xeba9('0x13')](_0x475174,_0x3c04e5);var _0xd132f5=_0x5277c8[_0xeba9('0x15')](_0x4de610,_0xeba9('0x1f'),_0xeba9('0x20'));_0xd132f5+=_0x5277c8[_0xeba9('0x1c')](_0xeba9('0x20'));return _0xd132f5;};exports[_0xeba9('0x21')]=function(_0x25c852,_0x4f3c4b,_0x35f3d4){var _0x5c8529=_0x35f3d4||stringOptions[_0xeba9('0xa')];var _0x5361e4=_0x4f3c4b||stringOptions['secret'];var _0x5092b9=crypto[_0xeba9('0x1b')](_0x5c8529,_0x5361e4);var _0xc1c5da=_0x5092b9['update'](_0x25c852,_0xeba9('0x20'),_0xeba9('0x1f'));_0xc1c5da+=_0x5092b9[_0xeba9('0x1c')]('utf8');return _0xc1c5da;};
\ No newline at end of file
+var _0xc325=['aes192','encrypt','algorithm','join','is\x20not\x20a\x20supported\x20algorithm.\x20Your\x20system\x20supports\x20the\x20following\x20algorithms:','test','getCiphers','filter','indexOf','hasOwnProperty','encryptFile','createReadStream','createCipher','data','update','binary','write','end','unlink','decryptFile','createWriteStream','createDecipher','final','close','encryptString','secret','utf8','base64','decryptString','crypto','lodash','../../config/environment','../../config/logger','app','secrets'];(function(_0x22ee0f,_0x22e6d2){var _0x204696=function(_0x4cab38){while(--_0x4cab38){_0x22ee0f['push'](_0x22ee0f['shift']());}};_0x204696(++_0x22e6d2);}(_0xc325,0x112));var _0x5c32=function(_0x3bf83f,_0x181cac){_0x3bf83f=_0x3bf83f-0x0;var _0x22c4a9=_0xc325[_0x3bf83f];return _0x22c4a9;};'use strict';var crypto=require(_0x5c32('0x0'));var fs=require('fs');var BPromise=require('bluebird');var _=require(_0x5c32('0x1'));var config=require(_0x5c32('0x2'));var logger=require(_0x5c32('0x3'))(_0x5c32('0x4'));const AES_SUPPORTED_RX=/^aes(-)?\d{3}(-(cbc|cfb|ctr)(1|8)?){0,1}$/;const stringOptions={'secret':config[_0x5c32('0x5')]['session'],'algorithm':'aes-256-ctr'};const fileOptions={'algorithm':_0x5c32('0x6')};if(config[_0x5c32('0x7')]&&config[_0x5c32('0x7')][_0x5c32('0x8')]){var isSupported=isAlgorithmSupported(config['encrypt'][_0x5c32('0x8')]);if(isSupported){fileOptions[_0x5c32('0x8')]=config[_0x5c32('0x7')]['algorithm'];}else{var supportedAlgorithms=getSupportedCiphers()[_0x5c32('0x9')](',\x20');logger['error'](config[_0x5c32('0x7')][_0x5c32('0x8')],_0x5c32('0xa'),supportedAlgorithms);}}function isASupportedCipher(_0x2761c3){return AES_SUPPORTED_RX[_0x5c32('0xb')](_0x2761c3);}function getSupportedCiphers(){return crypto[_0x5c32('0xc')]()[_0x5c32('0xd')](isASupportedCipher);}function isAlgorithmSupported(_0xf20692){return getSupportedCiphers()[_0x5c32('0xe')](_0xf20692)>-0x1;}function combineOptions(_0x41be88){var _0x15d004={};for(var _0x2bba0d in fileOptions){if(fileOptions[_0x5c32('0xf')](_0x2bba0d)){_0x15d004[_0x2bba0d]=fileOptions[_0x2bba0d];}}if(_0x41be88){for(var _0x35e7b7 in _0x41be88){if(_0x41be88[_0x5c32('0xf')](_0x35e7b7)){_0x15d004[_0x35e7b7]=_0x41be88[_0x35e7b7];}}}return _0x15d004;}exports[_0x5c32('0x10')]=function(_0xf2af49,_0x59de10,_0x1dec58,_0x52110d){return new BPromise(function(_0x423b12,_0x2bbf4a){_0x52110d=combineOptions(_0x52110d);var _0x161924=new Buffer(_0x1dec58);var _0x32c9dd=fs[_0x5c32('0x11')](_0xf2af49);var _0x4043d9=fs['createWriteStream'](_0x59de10);var _0xc9562=crypto[_0x5c32('0x12')](_0x52110d[_0x5c32('0x8')],_0x161924);_0x32c9dd['on'](_0x5c32('0x13'),function(_0x5f2dcf){var _0x5c4606=new Buffer(_0xc9562[_0x5c32('0x14')](_0x5f2dcf),_0x5c32('0x15'));_0x4043d9[_0x5c32('0x16')](_0x5c4606);});_0x32c9dd['on'](_0x5c32('0x17'),function(){try{var _0x5db851=new Buffer(_0xc9562['final']('binary'),'binary');_0x4043d9['write'](_0x5db851);_0x4043d9[_0x5c32('0x17')]();_0x4043d9['on']('close',function(){return _0x423b12(_0x59de10);});}catch(_0x3477f7){fs[_0x5c32('0x18')](_0x59de10);return _0x2bbf4a(_0x3477f7);}});});};exports[_0x5c32('0x19')]=function(_0x37488e,_0x1f2676,_0x4da24e,_0x566c28){return new BPromise(function(_0x6d7124,_0x29dce0){_0x566c28=combineOptions(_0x566c28);var _0x5a0b3f=new Buffer(_0x4da24e);var _0x4722c8=fs[_0x5c32('0x11')](_0x37488e);var _0x3342e0=fs[_0x5c32('0x1a')](_0x1f2676);var _0xc899e1=crypto[_0x5c32('0x1b')](_0x566c28['algorithm'],_0x5a0b3f);_0x4722c8['on']('data',function(_0x4577f4){var _0x4e2f3a=new Buffer(_0xc899e1['update'](_0x4577f4),_0x5c32('0x15'));_0x3342e0['write'](_0x4e2f3a);});_0x4722c8['on']('end',function(){try{var _0x557365=new Buffer(_0xc899e1[_0x5c32('0x1c')](_0x5c32('0x15')),_0x5c32('0x15'));_0x3342e0[_0x5c32('0x16')](_0x557365);_0x3342e0['end']();_0x3342e0['on'](_0x5c32('0x1d'),function(){return _0x6d7124(_0x1f2676);});}catch(_0xa176bb){fs[_0x5c32('0x18')](_0x1f2676);return _0x29dce0(_0xa176bb);}});});};exports[_0x5c32('0x1e')]=function(_0x23f659,_0x446068,_0x11bb22){var _0xa9188d=_0x11bb22||stringOptions[_0x5c32('0x8')];var _0x34f9ff=_0x446068||stringOptions[_0x5c32('0x1f')];var _0xa9b86c=crypto[_0x5c32('0x12')](_0xa9188d,_0x34f9ff);var _0x3b6c81=_0xa9b86c[_0x5c32('0x14')](_0x23f659,_0x5c32('0x20'),_0x5c32('0x21'));_0x3b6c81+=_0xa9b86c[_0x5c32('0x1c')](_0x5c32('0x21'));return _0x3b6c81;};exports[_0x5c32('0x22')]=function(_0x307a1d,_0x654bd2,_0x28a59c){var _0x11f41f=_0x28a59c||stringOptions[_0x5c32('0x8')];var _0x23496d=_0x654bd2||stringOptions[_0x5c32('0x1f')];var _0x3ab11d=crypto['createDecipher'](_0x11f41f,_0x23496d);var _0x3c04d7=_0x3ab11d[_0x5c32('0x14')](_0x307a1d,'base64',_0x5c32('0x20'));_0x3c04d7+=_0x3ab11d[_0x5c32('0x1c')]('utf8');return _0x3c04d7;};
\ No newline at end of file