示例#1
0
        public bool Save()
        {
            if (_originalCred != null)
            {
                try
                {
                    try // To delete the current stuff, you have to know the old stuff...
                    {
                        new PasswordVault().Remove(new PasswordCredential("SteamAuthenticator", "Storage", Encryptor.DPAPIUnprotect(_originalCred)));
                    }
                    catch (Exception)
                    {
                        //    System.Windows.MessageBox.Show("Failed to remove existing manifest!", "CredManifest");
                    }
                }
                catch (Exception)
                {
                    return(false);
                }
            }

            if (!Manifest.RememberPasskey)
            {
                UnsecureKey = ""; // 'Flush' it from memory then save the manifest. Note: unless the key gets resubmitted to CredManifest, it wont know the key until a program restart
            }
            else
            {
                Key = Key; // This refreshes the unsecure and secure copy
            }
            _originalCred = JsonConvert.SerializeObject(this);
            if (Manifest.UseDPAPI)
            {
                new PasswordVault().Add(new PasswordCredential("SteamAuthenticator", "Storage", Encryptor.DPAPIProtect(_originalCred)));
            }
            else
            {
                new PasswordVault().Add(new PasswordCredential("SteamAuthenticator", "Storage", _originalCred));
            }
            return(true);
        }