Skip to content

Commit

Permalink
Replace delay with Task.Run in keystore crack sub session
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeliux committed Sep 6, 2024
1 parent 13016ce commit e846f7f
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions cli/Kryptor.Cli.Shared/KeyStoreAnalyze/CrackSubSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,27 @@ public CrackSubSession(int index, byte[] test) : base()

protected override async Task<bool> RunAsync(ISessionHost sessionHost, CancellationToken cancellationToken)
{
await AsyncCompat.Delay(2, cancellationToken);

byte[] buffer = new byte[3];
buffer[0] = (byte)Index;

for (int b1 = 0; b1 <= 255; b1++)
await Task.Run(() =>
{
for (int b2 = 0; b2 <= 255; b2++)
byte[] buffer = new byte[3];
buffer[0] = (byte)Index;

for (int b1 = 0; b1 <= 255; b1++)
{
cancellationToken.ThrowIfCancellationRequested();
for (int b2 = 0; b2 <= 255; b2++)
{
cancellationToken.ThrowIfCancellationRequested();

buffer[1] = (byte)b1;
buffer[2] = (byte)b2;
buffer[1] = (byte)b1;
buffer[2] = (byte)b2;

if (buffer.Sha256().SequenceEqual(Test))
{
OnVerify?.Invoke();
if (buffer.Sha256().SequenceEqual(Test))
{
OnVerify?.Invoke();
}
}
}
}
});

return true;
}
Expand Down

0 comments on commit e846f7f

Please sign in to comment.