public void AddNewPassword() { if (string.IsNullOrEmpty(Title)) { WindowToolTip = "Please fill the title"; return; } if (string.IsNullOrEmpty(AddPassword)) { WindowToolTip = "Please enter the password!"; } if (!Website.StartsWith("https://")) { Website = "https://" + Website; } if (AvatarHashTable.ContainsKey(Title.ToLower())) { Avatar = (string)AvatarHashTable[Title.ToLower()]; } else { Avatar = "asset/default.png"; } //对密码加密 string encryptedPassword = Encryptor.AESEncrypt(AddPassword, KeyPassword); db.InsertNewPw(Title, Account, encryptedPassword, Website, Avatar); PasswordItem passwordItem = new PasswordItem(Title, Account, AddPassword, Website, Avatar); AddAPwItemToPwList(passwordItem); ClearAddNewPwForm(); DefaultVisibility = "Visible"; AddNewPwFormVisibility = "Hidden"; }