任何人都可以向我解释一下这个 delphi 代码在做什么吗?
我知道它正在移动一些位,但我不明白目的..
function PKV_GetKeyByte(const Seed : Int64; a, b, c : Byte) : Byte;
begin
a := a mod 25;
b := b mod 3;
if a mod 2 = 0 then
result := ((Seed shr a) and $000000FF) xor ((Seed shr b) or c)
else
result := ((Seed shr a) and $000000FF) xor ((Seed shr b) and c);
end;
我如何将其转换为 C#?
这是我到目前为止得到的:
private byte PKV_GetKeyByte(Int64 seed, byte a, byte b, byte c)
{
byte result;
int aVal = a % 25;
int bVal = b % 3;
//IF-IS-MISSING
if(a % 2 == 0)
{
}
else
{
}
return result;
}
最佳答案
我相信(未经测试)您想要类似...
result := ((Seed shr a) and $000000FF) xor ((Seed shr b) or c))
去
result = System.Convert.ToByte((Seed >> a) & 0x000000FF) ^ ((Seed >> b) | c));
和
result := ((Seed shr a) and $000000FF) xor ((Seed shr b) and c));
去
result = System.Convert.ToByte((Seed >> a) & 0x000000FF) ^ ((Seed >> b) & c));
关于c# - 理解这个delphi方法并将其转换为C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48419899/