mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-25 10:05:49 +08:00
* 更多更新渠道的UI改造 * CDK存储逻辑 * feat: enhance CDK input dialog with left button and update check logic for Alpha channel * 支持修改cdk * 支持删除cdk
52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using System;
|
|
using Meziantou.Framework.Win32;
|
|
|
|
namespace BetterGenshinImpact.Helpers.Win32;
|
|
|
|
public static class CredentialManagerHelper
|
|
{
|
|
public static void SaveCredential(string applicationName, string userName, string secret, string comment,
|
|
CredentialPersistence persistence)
|
|
{
|
|
CredentialManager.WriteCredential(
|
|
applicationName: applicationName,
|
|
userName: userName,
|
|
secret: secret,
|
|
comment: comment,
|
|
persistence: persistence);
|
|
}
|
|
|
|
public static Credential? ReadCredential(string applicationName)
|
|
{
|
|
var credential = CredentialManager.ReadCredential(applicationName);
|
|
if (credential == null)
|
|
{
|
|
Console.WriteLine("No credential found.");
|
|
return null;
|
|
}
|
|
|
|
Console.WriteLine($"UserName: {credential.UserName}");
|
|
Console.WriteLine($"Secret: {credential.Password}");
|
|
Console.WriteLine($"Comment: {credential.Comment}");
|
|
|
|
return credential;
|
|
}
|
|
|
|
public static void UpdateCredential(string applicationName, string newUserName, string newSecret, string newComment)
|
|
{
|
|
SaveCredential(applicationName, newUserName, newSecret, newComment, CredentialPersistence.LocalMachine);
|
|
}
|
|
|
|
public static void DeleteCredential(string applicationName)
|
|
{
|
|
try
|
|
{
|
|
CredentialManager.DeleteCredential(applicationName);
|
|
Console.WriteLine("Credential deleted successfully.");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"Error deleting credential: {ex.Message}");
|
|
}
|
|
}
|
|
} |