Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Fix hunter's well known Auto Shot bug #311

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -508,4 +508,4 @@ FodyWeavers.xsd

.idea/
*.DotSettings
debug.*.cs
debug.*
52 changes: 52 additions & 0 deletions Framework/Cryptography/Sha1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
namespace Framework.Cryptography;

public sealed class Sha1
{
private byte[] _s;

private byte _tmp;

private byte _tmp2;

public Sha1()
{
_s = new byte[256];
_tmp = 0;
_tmp2 = 0;
}

public void SetBase(byte[] key)
{
for (int i = 0; i < 256; i++)
{
_s[i] = (byte)i;
}
int num = 0;
for (int j = 0; j < 256; j++)
{
num = (byte)((num + key[j % key.Length] + _s[j]) & 0xFF);
ref byte reference = ref _s[j];
ref byte reference2 = ref _s[num];
byte b = _s[num];
byte b2 = _s[j];
reference = b;
reference2 = b2;
}
}

public void ProcessBuffer(byte[] data, int length)
{
for (int i = 0; i < length; i++)
{
_tmp = (byte)((_tmp + 1) % 256);
_tmp2 = (byte)((_tmp2 + _s[_tmp]) % 256);
ref byte reference = ref _s[_tmp];
ref byte reference2 = ref _s[_tmp2];
byte b = _s[_tmp2];
byte b2 = _s[_tmp];
reference = b;
reference2 = b2;
data[i] = (byte)(_s[(_s[_tmp] + _s[_tmp2]) % 256] ^ data[i]);
}
}
}
Loading