File tree Expand file tree Collapse file tree 1 file changed +13
-20
lines changed Expand file tree Collapse file tree 1 file changed +13
-20
lines changed Original file line number Diff line number Diff line change 77
88class Decrypt
99{
10- protected $ secEnv ;
10+ protected $ configkey ;
1111
1212 function __construct ()
1313 {
1414 $ configkey = (new ConfigKey )->get ();
1515
16- if (!empty ($ configkey )) {
17-
18- $ configfile = (new ConfigFile )->get ();
19-
20- !empty ($ configkey ) && count ($ configfile ) && $ crypt = new Encrypter ($ configkey );
21-
22- $ secEnv = [];
23-
24- foreach ($ configfile as $ key => $ value ) {
25- //exclude config values that are arrays and test for ENC: prefix in each value
26- if (!is_array ($ value ) && strpos ($ value , "ENC: " ) === 0 ) {
27- //Decrypt values with ENC: prefix
28- $ secEnv [$ key ] = $ crypt ->decrypt (substr ($ value , 4 ));
29- }
30- }
31-
32- $ this ->secEnv = $ secEnv ;
33- }
16+ !empty ($ configkey ) && $ this ->configkey = $ configkey ;
3417 }
3518
3619 /**
@@ -42,6 +25,16 @@ function __construct()
4225 */
4326 public function get ($ name )
4427 {
45- return isset ($ this ->secEnv [$ name ]) ? $ this ->secEnv [$ name ] : null ;
28+ $ configfile = (new ConfigFile )->get ();
29+
30+ if (!empty ($ this ->configkey ) && count ($ configfile )) {
31+
32+ $ crypt = new Encrypter ($ this ->configkey );
33+
34+ return !empty ($ configfile [$ name ]) && !is_array ($ configfile [$ name ]) && strpos ($ configfile [$ name ], "ENC: " ) === 0 ?
35+ $ crypt ->decrypt (substr ($ configfile [$ name ], 4 )) :
36+ null ;
37+ }
38+ return null ;
4639 }
4740}
You can’t perform that action at this time.
0 commit comments