@@ -106,6 +106,8 @@ public static function get($field, $source = null, $default = null, $possible_va
106
106
$ value = isset ($ source [$ field ]) ? $ source [$ field ] : $ default ;
107
107
} else if (is_object ($ source )) {
108
108
$ value = isset ($ source ->{$ field }) ? $ source ->{$ field } : $ default ;
109
+ } else {
110
+ $ value = $ default ;
109
111
}
110
112
111
113
if ($ possible_values ) {
@@ -231,10 +233,6 @@ public static function in_string($needle, $string) {
231
233
} else return stripos ($ string , $ needle ) !== false ;
232
234
}
233
235
234
- public static function hash ($ str ) {
235
- return hash ('sha256 ' , $ str );
236
- }
237
-
238
236
public static function save_session_result ($ data ) {
239
237
$ uuid = self ::uuid ();
240
238
$ _SESSION [$ uuid ] = json_encode ($ data );
@@ -582,7 +580,7 @@ public static function encrypt($data, $key, $iv) {
582
580
$ output = false ;
583
581
$ encrypt_method = "AES-256-CBC " ;
584
582
// hash
585
- $ key = self :: hash ( $ key );
583
+ $ key = hash_hmac ( ' sha256 ' , $ data , $ iv );
586
584
587
585
// iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning
588
586
$ iv = substr ($ iv , 0 , 16 );
@@ -599,7 +597,7 @@ public static function decrypt($data, $key, $iv) {
599
597
$ output = false ;
600
598
$ encrypt_method = "AES-256-CBC " ;
601
599
// hash
602
- $ key = self :: hash ( $ key );
600
+ $ key = hash_hmac ( ' sha256 ' , $ data , $ iv );
603
601
604
602
// iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning
605
603
$ iv = substr ($ iv , 0 , 16 );
0 commit comments