Skip to content

Commit

Permalink
feat: 增加加密测试
Browse files Browse the repository at this point in the history
  • Loading branch information
Loskh authored and wozaiha committed Feb 19, 2025
1 parent b386a01 commit 1d718f6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/XIVLauncher/Accounts/AccountManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ public async void ChangeCredType(CredType? type)
throw new Exception($"Cred type: {type} not supported");
}

var testText = EncryptionHelper.GetRandomHexString(32);
var encrypted = await newCred.Encrypt(testText);
var decrypted = await newCred.Decrypt(encrypted);

if (testText != decrypted)
{
throw new Exception($"Cred type: {type} test failed");
}

if (oldCred == null)
{
this.CurrentCredType = type;
Expand Down Expand Up @@ -96,11 +105,12 @@ public async void ChangeCredType(CredType? type)
Log.Error(ex, $"Failed to change {item.Id}.TestSID");
}
}
Save();
}

this.CurrentCredType = type;
this.CredProvider = newCred;
Log.Information($"Changed cred type from {this.CurrentCredType} to {type} successfully");
Save();
}

private ICredProvider GetCredProvider(CredType type)
Expand Down Expand Up @@ -200,7 +210,6 @@ public void Save()
{
this.Save(item);
}
ChangeCredType(this.CurrentCredType);
}

public void SetupDb()
Expand Down

0 comments on commit 1d718f6

Please sign in to comment.