Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / components / encryptor / index.js
index ce96eba..350a17a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3c4a=['encryptFile','createReadStream','createWriteStream','data','update','binary','write','end','final','unlink','decryptFile','close','encryptString','createCipher','utf8','base64','secret','createDecipher','crypto','bluebird','lodash','../../config/environment','app','aes192','encrypt','algorithm','join','error','is\x20not\x20a\x20supported\x20algorithm.\x20Your\x20system\x20supports\x20the\x20following\x20algorithms:','getCiphers','filter','indexOf','hasOwnProperty'];(function(_0x29eec4,_0xa6e66){var _0xee5587=function(_0x4a7dd5){while(--_0x4a7dd5){_0x29eec4['push'](_0x29eec4['shift']());}};_0xee5587(++_0xa6e66);}(_0x3c4a,0x15c));var _0xa3c4=function(_0x5e4a4c,_0x1b8d7e){_0x5e4a4c=_0x5e4a4c-0x0;var _0x1afefb=_0x3c4a[_0x5e4a4c];return _0x1afefb;};'use strict';var crypto=require(_0xa3c4('0x0'));var fs=require('fs');var BPromise=require(_0xa3c4('0x1'));var _=require(_0xa3c4('0x2'));var config=require(_0xa3c4('0x3'));var logger=require('../../config/logger')(_0xa3c4('0x4'));const AES_SUPPORTED_RX=/^aes(-)?\d{3}(-(cbc|cfb|ctr)(1|8)?){0,1}$/;const stringOptions={'secret':config['secrets']['session'],'algorithm':'aes-256-ctr'};const fileOptions={'algorithm':_0xa3c4('0x5')};if(config[_0xa3c4('0x6')]&&config[_0xa3c4('0x6')][_0xa3c4('0x7')]){var isSupported=isAlgorithmSupported(config['encrypt'][_0xa3c4('0x7')]);if(isSupported){fileOptions[_0xa3c4('0x7')]=config[_0xa3c4('0x6')]['algorithm'];}else{var supportedAlgorithms=getSupportedCiphers()[_0xa3c4('0x8')](',\x20');logger[_0xa3c4('0x9')](config[_0xa3c4('0x6')][_0xa3c4('0x7')],_0xa3c4('0xa'),supportedAlgorithms);}}function isASupportedCipher(_0x5582cc){return AES_SUPPORTED_RX['test'](_0x5582cc);}function getSupportedCiphers(){return crypto[_0xa3c4('0xb')]()[_0xa3c4('0xc')](isASupportedCipher);}function isAlgorithmSupported(_0x5656c3){return getSupportedCiphers()[_0xa3c4('0xd')](_0x5656c3)>-0x1;}function combineOptions(_0x370424){var _0x300c55={};for(var _0x666151 in fileOptions){if(fileOptions['hasOwnProperty'](_0x666151)){_0x300c55[_0x666151]=fileOptions[_0x666151];}}if(_0x370424){for(var _0x47f3e8 in _0x370424){if(_0x370424[_0xa3c4('0xe')](_0x47f3e8)){_0x300c55[_0x47f3e8]=_0x370424[_0x47f3e8];}}}return _0x300c55;}exports[_0xa3c4('0xf')]=function(_0x5529c7,_0x165e2f,_0x22aadc,_0x49fe1d){return new BPromise(function(_0x38ceb1,_0x50e76d){_0x49fe1d=combineOptions(_0x49fe1d);var _0x34ef84=new Buffer(_0x22aadc);var _0x289841=fs[_0xa3c4('0x10')](_0x5529c7);var _0x4d8671=fs[_0xa3c4('0x11')](_0x165e2f);var _0x3f1208=crypto['createCipher'](_0x49fe1d['algorithm'],_0x34ef84);_0x289841['on'](_0xa3c4('0x12'),function(_0x10eb18){var _0x50c001=new Buffer(_0x3f1208[_0xa3c4('0x13')](_0x10eb18),_0xa3c4('0x14'));_0x4d8671[_0xa3c4('0x15')](_0x50c001);});_0x289841['on'](_0xa3c4('0x16'),function(){try{var _0x79d095=new Buffer(_0x3f1208[_0xa3c4('0x17')](_0xa3c4('0x14')),_0xa3c4('0x14'));_0x4d8671[_0xa3c4('0x15')](_0x79d095);_0x4d8671['end']();_0x4d8671['on']('close',function(){return _0x38ceb1(_0x165e2f);});}catch(_0x167a4d){fs[_0xa3c4('0x18')](_0x165e2f);return _0x50e76d(_0x167a4d);}});});};exports[_0xa3c4('0x19')]=function(_0x19069b,_0x393fc4,_0x40e967,_0x12b179){return new BPromise(function(_0x3d5573,_0x507f8b){_0x12b179=combineOptions(_0x12b179);var _0x4bddea=new Buffer(_0x40e967);var _0x5d14b1=fs[_0xa3c4('0x10')](_0x19069b);var _0x4188cf=fs[_0xa3c4('0x11')](_0x393fc4);var _0x3477a1=crypto['createDecipher'](_0x12b179[_0xa3c4('0x7')],_0x4bddea);_0x5d14b1['on']('data',function(_0x36fa85){var _0x5b9c4e=new Buffer(_0x3477a1[_0xa3c4('0x13')](_0x36fa85),_0xa3c4('0x14'));_0x4188cf[_0xa3c4('0x15')](_0x5b9c4e);});_0x5d14b1['on']('end',function(){try{var _0x4640d1=new Buffer(_0x3477a1['final'](_0xa3c4('0x14')),_0xa3c4('0x14'));_0x4188cf['write'](_0x4640d1);_0x4188cf[_0xa3c4('0x16')]();_0x4188cf['on'](_0xa3c4('0x1a'),function(){return _0x3d5573(_0x393fc4);});}catch(_0xebf6c){fs[_0xa3c4('0x18')](_0x393fc4);return _0x507f8b(_0xebf6c);}});});};exports[_0xa3c4('0x1b')]=function(_0x1e68bb,_0x10c697,_0x5e5ce8){var _0x27eda3=_0x5e5ce8||stringOptions[_0xa3c4('0x7')];var _0x5cd05c=_0x10c697||stringOptions['secret'];var _0x223416=crypto[_0xa3c4('0x1c')](_0x27eda3,_0x5cd05c);var _0x149ba0=_0x223416[_0xa3c4('0x13')](_0x1e68bb,_0xa3c4('0x1d'),_0xa3c4('0x1e'));_0x149ba0+=_0x223416['final']('base64');return _0x149ba0;};exports['decryptString']=function(_0x4158e1,_0x167352,_0x5f1400){var _0x6d0d02=_0x5f1400||stringOptions[_0xa3c4('0x7')];var _0x59b8d5=_0x167352||stringOptions[_0xa3c4('0x1f')];var _0x3aa381=crypto[_0xa3c4('0x20')](_0x6d0d02,_0x59b8d5);var _0x211f22=_0x3aa381[_0xa3c4('0x13')](_0x4158e1,_0xa3c4('0x1e'),_0xa3c4('0x1d'));_0x211f22+=_0x3aa381[_0xa3c4('0x17')](_0xa3c4('0x1d'));return _0x211f22;};
\ No newline at end of file
+var _0x87d6=['encrypt','algorithm','join','error','is\x20not\x20a\x20supported\x20algorithm.\x20Your\x20system\x20supports\x20the\x20following\x20algorithms:','indexOf','hasOwnProperty','encryptFile','createReadStream','createWriteStream','createCipher','data','binary','write','end','close','unlink','decryptFile','createDecipher','update','utf8','base64','final','decryptString','secret','lodash','../../config/environment','../../config/logger','app','secrets','session','aes-256-ctr','aes192'];(function(_0xb9a43a,_0x14b436){var _0xedabd8=function(_0x4142fe){while(--_0x4142fe){_0xb9a43a['push'](_0xb9a43a['shift']());}};_0xedabd8(++_0x14b436);}(_0x87d6,0xbe));var _0x687d=function(_0x3740fe,_0x6c543c){_0x3740fe=_0x3740fe-0x0;var _0x55492b=_0x87d6[_0x3740fe];return _0x55492b;};'use strict';var crypto=require('crypto');var fs=require('fs');var BPromise=require('bluebird');var _=require(_0x687d('0x0'));var config=require(_0x687d('0x1'));var logger=require(_0x687d('0x2'))(_0x687d('0x3'));const AES_SUPPORTED_RX=/^aes(-)?\d{3}(-(cbc|cfb|ctr)(1|8)?){0,1}$/;const stringOptions={'secret':config[_0x687d('0x4')][_0x687d('0x5')],'algorithm':_0x687d('0x6')};const fileOptions={'algorithm':_0x687d('0x7')};if(config[_0x687d('0x8')]&&config[_0x687d('0x8')]['algorithm']){var isSupported=isAlgorithmSupported(config[_0x687d('0x8')]['algorithm']);if(isSupported){fileOptions[_0x687d('0x9')]=config[_0x687d('0x8')][_0x687d('0x9')];}else{var supportedAlgorithms=getSupportedCiphers()[_0x687d('0xa')](',\x20');logger[_0x687d('0xb')](config[_0x687d('0x8')][_0x687d('0x9')],_0x687d('0xc'),supportedAlgorithms);}}function isASupportedCipher(_0xc3ddbe){return AES_SUPPORTED_RX['test'](_0xc3ddbe);}function getSupportedCiphers(){return crypto['getCiphers']()['filter'](isASupportedCipher);}function isAlgorithmSupported(_0x3c4078){return getSupportedCiphers()[_0x687d('0xd')](_0x3c4078)>-0x1;}function combineOptions(_0xb29b25){var _0x5c3823={};for(var _0x5338ea in fileOptions){if(fileOptions['hasOwnProperty'](_0x5338ea)){_0x5c3823[_0x5338ea]=fileOptions[_0x5338ea];}}if(_0xb29b25){for(var _0x399cbc in _0xb29b25){if(_0xb29b25[_0x687d('0xe')](_0x399cbc)){_0x5c3823[_0x399cbc]=_0xb29b25[_0x399cbc];}}}return _0x5c3823;}exports[_0x687d('0xf')]=function(_0x4d0f06,_0x18bfdb,_0x3645e0,_0x4903a8){return new BPromise(function(_0x10a2a5,_0x3a55a2){_0x4903a8=combineOptions(_0x4903a8);var _0x5e933a=new Buffer(_0x3645e0);var _0x48bd8a=fs[_0x687d('0x10')](_0x4d0f06);var _0x1c2bdc=fs[_0x687d('0x11')](_0x18bfdb);var _0xbf03b7=crypto[_0x687d('0x12')](_0x4903a8[_0x687d('0x9')],_0x5e933a);_0x48bd8a['on'](_0x687d('0x13'),function(_0x4cc976){var _0xe6fa35=new Buffer(_0xbf03b7['update'](_0x4cc976),_0x687d('0x14'));_0x1c2bdc[_0x687d('0x15')](_0xe6fa35);});_0x48bd8a['on'](_0x687d('0x16'),function(){try{var _0xf7d52f=new Buffer(_0xbf03b7['final'](_0x687d('0x14')),_0x687d('0x14'));_0x1c2bdc[_0x687d('0x15')](_0xf7d52f);_0x1c2bdc[_0x687d('0x16')]();_0x1c2bdc['on'](_0x687d('0x17'),function(){return _0x10a2a5(_0x18bfdb);});}catch(_0xaa59d5){fs[_0x687d('0x18')](_0x18bfdb);return _0x3a55a2(_0xaa59d5);}});});};exports[_0x687d('0x19')]=function(_0x452a30,_0x9acc13,_0x17d578,_0x2cd74b){return new BPromise(function(_0x584749,_0x3c6900){_0x2cd74b=combineOptions(_0x2cd74b);var _0x5ab64e=new Buffer(_0x17d578);var _0x59d30d=fs[_0x687d('0x10')](_0x452a30);var _0x3d5582=fs[_0x687d('0x11')](_0x9acc13);var _0x4f6a7e=crypto[_0x687d('0x1a')](_0x2cd74b[_0x687d('0x9')],_0x5ab64e);_0x59d30d['on']('data',function(_0x2bdbc9){var _0x26faaa=new Buffer(_0x4f6a7e[_0x687d('0x1b')](_0x2bdbc9),_0x687d('0x14'));_0x3d5582['write'](_0x26faaa);});_0x59d30d['on'](_0x687d('0x16'),function(){try{var _0x2cdce3=new Buffer(_0x4f6a7e['final'](_0x687d('0x14')),_0x687d('0x14'));_0x3d5582[_0x687d('0x15')](_0x2cdce3);_0x3d5582['end']();_0x3d5582['on'](_0x687d('0x17'),function(){return _0x584749(_0x9acc13);});}catch(_0xd4605d){fs['unlink'](_0x9acc13);return _0x3c6900(_0xd4605d);}});});};exports['encryptString']=function(_0x51f608,_0x28c620,_0x539a30){var _0x21e1d5=_0x539a30||stringOptions[_0x687d('0x9')];var _0x1591f1=_0x28c620||stringOptions['secret'];var _0x1118fc=crypto[_0x687d('0x12')](_0x21e1d5,_0x1591f1);var _0x5da1cf=_0x1118fc[_0x687d('0x1b')](_0x51f608,_0x687d('0x1c'),_0x687d('0x1d'));_0x5da1cf+=_0x1118fc[_0x687d('0x1e')](_0x687d('0x1d'));return _0x5da1cf;};exports[_0x687d('0x1f')]=function(_0x3602c1,_0x5c8845,_0x289085){var _0x199f84=_0x289085||stringOptions[_0x687d('0x9')];var _0x740452=_0x5c8845||stringOptions[_0x687d('0x20')];var _0x2656a5=crypto['createDecipher'](_0x199f84,_0x740452);var _0x3c5741=_0x2656a5['update'](_0x3602c1,_0x687d('0x1d'),_0x687d('0x1c'));_0x3c5741+=_0x2656a5[_0x687d('0x1e')](_0x687d('0x1c'));return _0x3c5741;};
\ No newline at end of file