一个C#算法分析求解

最近碰到这样一个算法,过程并不复杂,但是思考了很久也没有找到对应的逆运算算法,这里发布出来,希望有高人能够提供思路,
如果有具体的代码实现就最好了。
实现public static String ReCalc(byte[] buffer1)方法,保证
if(text==text1) Console.WriteLine("ok");
就可以了
 1None.gifString text="5UYTSHZ0PL4Q3RB26FD";
 2None.gifbyte[] mydata=new byte[12];
 3None.gifcalc_1(text,mydata);
 4None.gifString text1=ReCalc(data);
 5None.gifif(text==text1) Console.WriteLine("ok");
 6None.gif
 7None.gif//实现下面方法,满足上面条件
 8ExpandedBlockStart.gifContractedBlock.gifpublic static String ReCalc(byte[] buffer1)dot.gif{
 9InBlock.gif    return "";
10ExpandedBlockEnd.gif}

11None.gif
12None.gifpublic static void Calc(string text1, byte[] buffer1)
13ExpandedBlockStart.gifContractedBlock.gifdot.gif{
14InBlock.gif      ushort num1 = 11;
15InBlock.gif      uint num2 = 0;
16InBlock.gif      uint num3 = 0;
17InBlock.gif      int num4 = 0;
18InBlock.gif      while ((num2 < buffer1.Length) && (num3 < 90))
19ExpandedSubBlockStart.gifContractedSubBlock.gif      dot.gif{
20InBlock.gif            uint num5 = CalcNum(text1[num4++]);
21InBlock.gif            if (num5 == 0xffff)
22ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
23InBlock.gif                  throw new Exception("Error");
24ExpandedSubBlockEnd.gif            }

25InBlock.gif            num5 = num5 << (num1 & 0x1f);
26InBlock.gif            buffer1[num2] = Convert.ToByte(buffer1[num2] | ((num5 & 0xff00>> 8));
27InBlock.gif            buffer1[num2 + 1= Convert.ToByte(buffer1[num2 + 1| (num5 & 0xff));
28InBlock.gif            if (num1 < 8)
29ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
30InBlock.gif                  num1 += 3;
31InBlock.gif                  num2++;
32ExpandedSubBlockEnd.gif            }

33InBlock.gif            else
34ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
35InBlock.gif                  num1 -= 5;
36ExpandedSubBlockEnd.gif            }

37InBlock.gif            num3 += 5;
38ExpandedSubBlockEnd.gif      }

39ExpandedBlockEnd.gif}

40None.gif
41ExpandedBlockStart.gifContractedBlock.gifpublic static uint CalcNum(char c)dot.gif{
42InBlock.gif    String data="6HC3QBW9K2FUL8XJ4P0TN5DEAZ1YR7VG";
43ExpandedSubBlockStart.gifContractedSubBlock.gif    for(int i=0;i<data.Length;i++)dot.gif{
44InBlock.gif        if(data[i]==c) return (uint)i;
45ExpandedSubBlockEnd.gif    }

46InBlock.gif    return 0xffff;
47ExpandedBlockEnd.gif}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值