mirror of
https://github.com/crskycode/GARbro.git
synced 2026-07-08 01:30:18 +08:00
NotTransform and XorTransform implementations moved to separate file.
This commit is contained in:
@@ -83,42 +83,4 @@ namespace GameRes.Formats.X
|
||||
return new CryptoStream (input, new XorTransform (key), CryptoStreamMode.Read);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class XorTransform : ICryptoTransform
|
||||
{
|
||||
private const int BlockSize = 256;
|
||||
private byte m_key;
|
||||
|
||||
public bool CanReuseTransform { get { return true; } }
|
||||
public bool CanTransformMultipleBlocks { get { return true; } }
|
||||
public int InputBlockSize { get { return BlockSize; } }
|
||||
public int OutputBlockSize { get { return BlockSize; } }
|
||||
|
||||
public XorTransform (byte key)
|
||||
{
|
||||
m_key = key;
|
||||
}
|
||||
|
||||
public int TransformBlock (byte[] inputBuffer, int inputOffset, int inputCount,
|
||||
byte[] outputBuffer, int outputOffset)
|
||||
{
|
||||
for (int i = 0; i < inputCount; ++i)
|
||||
{
|
||||
outputBuffer[outputOffset++] = (byte)(m_key ^ inputBuffer[inputOffset+i]);
|
||||
}
|
||||
return inputCount;
|
||||
}
|
||||
|
||||
public byte[] TransformFinalBlock (byte[] inputBuffer, int inputOffset, int inputCount)
|
||||
{
|
||||
byte[] outputBuffer = new byte[inputCount];
|
||||
TransformBlock (inputBuffer, inputOffset, inputCount, outputBuffer, 0);
|
||||
return outputBuffer;
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
System.GC.SuppressFinalize (this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user