obfuz/Editor/EncryptionVM/Instructions/EncryptFunction.cs

48 lines
1.3 KiB
C#
Raw Permalink Normal View History

2025-05-06 09:13:24 +08:00
using System;
using System.Collections.Generic;
2025-05-06 09:13:24 +08:00
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2025-05-11 12:53:24 +08:00
namespace Obfuz.EncryptionVM.Instructions
2025-05-06 09:13:24 +08:00
{
2025-05-11 12:48:53 +08:00
public class EncryptFunction : EncryptionInstructionBase
2025-05-06 09:13:24 +08:00
{
2025-05-11 12:48:53 +08:00
private readonly IEncryptionInstruction[] _instructions;
2025-05-06 09:13:24 +08:00
2025-05-11 12:48:53 +08:00
public EncryptFunction(IEncryptionInstruction[] instructions)
2025-05-06 09:13:24 +08:00
{
_instructions = instructions;
}
public override int Encrypt(int value, int[] secretKey, int salt)
{
foreach (var instruction in _instructions)
{
value = instruction.Encrypt(value, secretKey, salt);
}
return value;
}
public override int Decrypt(int value, int[] secretKey, int salt)
{
for (int i = _instructions.Length - 1; i >= 0; i--)
{
value = _instructions[i].Decrypt(value, secretKey, salt);
}
return value;
}
public override void GenerateEncryptCode(List<string> lines, string indent)
{
throw new NotImplementedException();
}
public override void GenerateDecryptCode(List<string> lines, string indent)
{
throw new NotImplementedException();
}
2025-05-06 09:13:24 +08:00
}
}