I have this line in my code and I can't seem to understand how it works -(in order to find my problem)
0- (277 in HEX mode 256)
I know the result should be 89
checksum = 0- (277(16) mode 256)
but I don't remember why
this is the C#
byte[] ByteMessage = {0x30 , 0x31 , 0x48 , 0x41 , 0x4E , 0X4F , 0X56 , 0X45 , 0X52 , 0X03 }
byte answer = gen (ByteMessage )
public static byte gen(byte[] p)
{
byte lcs = 0;
foreach (byte b in p)
{
lcs += b;
}
lcs = (byte)(0 - lcs);
return lcs;
}