Getting the following error :
System.OverflowException has been thrown - Value was either too large or too small for an unsigned byte.
Does anyone have any idea how to fix it?
class MainClass
{
public static void Main(string[] args)
{
int decValue = 2210;
string bin = Convert.ToString(decValue, 2);
string lowerbyte = bin.Substring(Math.Max(0, bin.Length - 16));
if (lowerbyte.Length < 16)
{
lowerbyte = lowerbyte.PadLeft(16, '0');
}
Int16 circular = Convert.ToByte(CicrularLeftShift(lowerbyte, 3), 2);
string xored = Convert.ToString((circular ^ 38556), 2).Substring(Math.Max(0, Convert.ToString((circular ^ 38556), 2).Length - 16));
//converting final binary shift value to HEX
string finalHex = Convert.ToString(Convert.ToInt32(xored, 2), 16).ToUpper();
Console.WriteLine(finalHex);
}
private static string CicrularLeftShift(string key, int shift)
{
return key.Substring(shift, key.Length - shift) + key.Substring(0, shift);
}
}