private void Button_Clicked(object sender, EventArgs e) { var password = ViewModel.MasterPassword; var serviceName = ServicePersistor.GetServiceName(ViewModel.ServiceName); if (!String.IsNullOrEmpty(password) && !String.IsNullOrEmpty(serviceName)) { // Use one set of database vs a new database for a different master password var encryptedMaster = ServicePersistor.GetEncryptedFileName("DFtIETN"); // ServicePersistor.GetEncryptedFileName(password); var requirement = PasswordRequirements.None; SqliteStorage.InitializeStorage(IoCProviders.GetProvider <IKnowStorage>().GetStoragePath(), encryptedMaster); var serviceEntity = ServicePersistor.GetPasswordSettings(serviceName); if (serviceEntity != null) { requirement = (PasswordRequirements)serviceEntity.Requirements; ViewModel.IncludeNumbers = (requirement & PasswordRequirements.NumberRequired) > 0; ViewModel.IncludeSymbols = (requirement & PasswordRequirements.SymbolRequired) > 0; ViewModel.IncludeUppercase = (requirement & PasswordRequirements.UpperCaseRequired) > 0; } else { requirement |= ViewModel.IncludeNumbers ? PasswordRequirements.NumberRequired : PasswordRequirements.NoNumber; requirement |= ViewModel.IncludeSymbols ? PasswordRequirements.SymbolRequired : PasswordRequirements.NoSymbol; requirement |= ViewModel.IncludeUppercase ? PasswordRequirements.UpperCaseRequired : PasswordRequirements.None; } GeneratePassword(password, serviceName, requirement); } }
private void GeneratePassword(string password, string serviceName, PasswordRequirements requirement) { PasswordGenerator generator = new PasswordGenerator(requirement); ViewModel.Password = generator.GeneratePassword(password, serviceName, 10); // store settings ServicePersistor.Persist(serviceName, requirement); ViewModel.PasswordVisible = true; ViewModel.CreateNewPassword = true; IoCProviders.GetProvider <ICopyToClipboard>().CopyToClipboard(ViewModel.Password); IoCProviders.GetProvider <IProvideNotifications>().Notify(null, "Password has been copied to clipboard"); }
public App ( IKnowStorage storageProvider, ICopyToClipboard clipboardProvider, IProvideNotifications notificationProvider ) { InitializeComponent(); IoCProviders.Register <IKnowStorage>(storageProvider); IoCProviders.Register <ICopyToClipboard>(clipboardProvider); IoCProviders.Register <IProvideNotifications>(notificationProvider); MainPage = new PasswordManager.MainPage(); }