/** * Gets, and decrypts the database settings * * @return array|null */ public static function GetDatabaseSettings() { /** * Lets first read our settings */ $settings_encrypted = JsonReader::ReadFile('Json/database_settings.json'); /** * These settings are going to be encrypted, so thanks to our trusty cypher class, lets decrypt them! */ if ($settings_encrypted != null) { /** * Decrypt this array */ $settings_decrypted = Cyphers::DecryptArray($settings_encrypted); /** * Return it! */ return $settings_decrypted; } /** * Else, if we didn't find our settings, lets return null */ return null; }
/** * Encrypts our database settings * * @param $settings_payload * * @return bool */ public function EncryptDatabaseSettings($settings_payload) { /** * Lets check our data */ if (is_array($settings_payload) == false) { return false; } /** * Do we have all the keys? */ foreach ($this->database_keys as $key => $value) { if (isset($settings_payload[$value])) { continue; } /** * Return false, we've not got all our keys! */ return false; } /** * Great, I guess we have all our keys, lets encrypt this array! */ $encrypted_array = Cyphers::EncryptArray($settings_payload, true); /** * Then, lets write this to file */ JsonWriter::WriteFile('Json/database_settings.json', $encrypted_array); /** * Then, lets return true */ return true; }