private static void LoadFromFile(SettingsModel settingsModel) { while (true) { Console.Write("Enter passphrase: "); var passPhrase = EnterPassword(); Encrypter.PassPhrase = Encoding.UTF8.GetBytes(passPhrase); try { var encryptedData = File.ReadAllBytes(settingsModel.File); var json = encryptedData.Decrypt(settingsModel); var stateModel = Newtonsoft.Json.JsonConvert.DeserializeObject <StateModel>(json); NotebooksRepository.Init(stateModel.Notebooks); PagesRepository.Init(stateModel.Pages); PageContentRepository.Init(stateModel.Content); return; } catch (Exception) { Console.WriteLine("Invalid passphrase. Please try again..."); } } }