Skip to content

Commit

Permalink
Add key as initializable field in IGCipher
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaioru committed Nov 16, 2023
1 parent b631d2d commit eed460d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/common/Edelstein.Common.Crypto/IGCipher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public class IGCipher
{
private readonly byte[] _shuffle;
private readonly uint _key;

public IGCipher() : this(new byte[]
{
Expand All @@ -26,14 +27,16 @@ public IGCipher() : this(new byte[]
{
}

public IGCipher(byte[] shuffle) => _shuffle = shuffle;
public IGCipher(byte[] shuffle, uint key = 0xC65053F2)
{
_shuffle = shuffle;
_key = key;
}

public unsafe uint Hash(uint pSrc, int nLen, uint dwKey)
{
const uint dwDefaultKey = 0xC65053F2;

if (dwKey == 0) dwKey = dwDefaultKey;
if (nLen <= 0) return dwDefaultKey;
if (dwKey == 0) dwKey = _key;
if (nLen <= 0) return _key;

var ptrDwKey = &dwKey;

Expand Down

0 comments on commit eed460d

Please sign in to comment.