解码校验和代码

问题描述:

我需要解码以下代码,即使用代码



I need to decode the following code i.e use of code

public static string CalcChecksum(string instrFile)
    {
      ulong num1 = 0;
      uint num2 = 256;
      Tools.ReplaceChecksum(ref instrFile, "0000000000");
      byte[] bytes = Encoding.GetEncoding(1252).GetBytes(instrFile);
      int index = 0;
      while (index <= instrFile.Length - 1)
      {
        byte num3 = bytes[index];
        byte num4;
        byte num5;
        byte num6;
        if (index + 1 < instrFile.Length)
        {
          num4 = bytes[index + 1];
          if (index + 2 < instrFile.Length)
          {
            num5 = bytes[index + 2];
            num6 = index + 3 >= instrFile.Length ? (byte) 0 : bytes[index + 3];
          }
          else
          {
            num5 = (byte) 0;
            num6 = (byte) 0;
          }
        }
        else
        {
          num4 = (byte) 0;
          num5 = (byte) 0;
          num6 = (byte) 0;
        }
        ulong num7 = (ulong) (num2 * (num2 * (num2 * (uint) num3 + (uint) num4) + (uint) num5) + (uint) num6);
        num1 += num7;
        if (num1 > 4294967296UL)
          num1 -= 4294967296UL;
        index += 4;
      }
      return num1.ToString("0000000000");
    }





我的尝试:



我试过并输出一个与输入字符串对应的输出数字字符串。



What I have tried:

I have tried and get an output numeral string corresponding to input string to function.

问题是有几种不同形式的校验和,我们不知道您要尝试计算的类型,或者您应该使用的类型。它们的范围从试验summ和字节,扔掉并携带到SHA哈希!



结果我们无法告诉你怎么做修复你的方法 - 所以,这取决于你。

在函数的第一行放一个断点,然后通过调试器运行你的代码。然后查看您的代码,并查看您的数据并找出手动应该发生的事情。然后单步执行每一行检查您预期发生的情况正是如此。如果不是,那就是当你遇到问题时,你可以回溯(或者再次运行并仔细观察)以找出原因。



对不起,但我们不能为你做到这一点 - 时间让你学习一门新的(非常非常有用的)技能:调试!
The problem is that there are several different forms of checksum, and we have no idea what type you are trying to calculate, or what type you should be using. And they range from the trial "summ and the bytes and throw away and carry" to SHA hashes!

As a result we can't tell you what to do to fix your method - so, it's going to be up to you.
Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!