obfuz/Editor/Encryption/Instructions/XorInstruction.cs

25 lines
685 B
C#
Raw Normal View History

2025-05-11 12:48:53 +08:00
namespace Obfuz.Encryption.Instructions
2025-05-07 10:14:15 +08:00
{
2025-05-11 12:48:53 +08:00
public class XorInstruction : EncryptionInstructionBase
2025-05-07 10:14:15 +08:00
{
private readonly int _xorValue;
private readonly int _opKeyIndex;
public XorInstruction(int xorValue, int opKeyIndex)
{
_xorValue = xorValue;
_opKeyIndex = opKeyIndex;
}
public override int Encrypt(int value, int[] secretKey, int salt)
{
return value ^ secretKey[_opKeyIndex] ^ salt ^ _xorValue;
}
public override int Decrypt(int value, int[] secretKey, int salt)
{
return value ^ secretKey[_opKeyIndex] ^ salt ^ _xorValue;
}
}
}