读书人

C#转VB代码解决办法

发布时间: 2012-04-08 14:38:30 作者: rapoo

C#转VB代码
先摘一部分,因为我不知道代码的意思,如果少内容我就把全部代码贴出来.
我说的VB是指VB6.不是VB.NET 如果是.net就应该懂点C#了.

C# code
    private byte[] j = new byte[0x10000];    private byte[] k = new byte[] {         4, 0x3b, 0xc2, 0x7c, 0xec, 0xeb, 0x3f, 0x8b, 0x34, 0x83, 0x5b, 0x24, 0x43, 0xf8, 0x6a, 0x20,         0xc1, 0xe7, 2, 0xe8, 0x5c, 0xed, 0xf1, 0xff, 0x59, 0x8b, 13, 8, 0x33, 0x41, 0, 0x89     };    public void a(ref byte[] A_0)    {        byte num = A_0[0];        byte num2 = A_0[1];        if ((170 == num) && (0x55 == num2))        {            int num3 = BitConverter.ToInt16(A_0, 2);            if (num3 > 10)            {                byte num4 = A_0[num3 + 2];                num3 -= 3;                for (int i = 0; i < num3; i++)                {                    int index = i;                    index &= 0x1f;                    int num7 = this.k[index];                    num7 ^= num4;                    num7 = num7 << 8;                    num7 += A_0[i + 5] & 0xff;                    A_0[i + 5] = (byte) (0xff & this.j[num7]);                    num7 = 0;                }            }        }    }    public void a(long A_0)    {        int index = 0;        int[] numArray = new int[0x100];        for (int i = 0; i < 0x10000; i += 0x100)        {            long num4;            numArray = new int[0x100];            int num3 = 0;            goto Label_007A;        Label_0020:            num4 = A_0;            num4 *= 0x341fbL;            num4 += 0x267ec1L;            A_0 = num4;            num4 = num4 >> 0x10;            num4 &= 0x7fffL;            num4 &= 0xffL;            if (numArray[(int) ((IntPtr) num4)] != 0)            {                goto Label_0020;            }            numArray[(int) ((IntPtr) num4)] = 1;            this.j[index] = (byte) num4;            num3++;            index++;        Label_007A:            if (num3 < 0x100)            {                goto Label_0020;            }        }    }


作用应该就是数据解密用的.看能不能写成一个VB的函数.

[解决办法]
参考
VB code
Private j As Byte() = New Byte(65535) {}Private k As Byte() = New Byte() {4, &H3b, &Hc2, &H7c, &Hec, &Heb, _    &H3f, &H8b, &H34, &H83, &H5b, &H24, _    &H43, &Hf8, &H6a, &H20, &Hc1, &He7, _    2, &He8, &H5c, &Hed, &Hf1, &Hff, _    &H59, &H8b, 13, 8, &H33, &H41, _    0, &H89}Public Sub a(ByRef A_0 As Byte())    Dim num As Byte = A_0(0)    Dim num2 As Byte = A_0(1)    If (170 = num) AndAlso (&H55 = num2) Then        Dim num3 As Integer = BitConverter.ToInt16(A_0, 2)        If num3 > 10 Then            Dim num4 As Byte = A_0(num3 + 2)            num3 -= 3            For i As Integer = 0 To num3 - 1                Dim index As Integer = i                index = index And &H1f                Dim num7 As Integer = Me.k(index)                num7 = num7 Xor num4                num7 = num7 << 8                num7 += A_0(i + 5) And &Hff                A_0(i + 5) = CByte(&Hff And Me.j(num7))                num7 = 0            Next        End If    End IfEnd SubPublic Sub a(A_0 As Long)    Dim index As Integer = 0    Dim numArray As Integer() = New Integer(255) {}    For i As Integer = 0 To 65535 Step 256        Dim num4 As Long        numArray = New Integer(255) {}        Dim num3 As Integer = 0        GoTo Label_007A        Label_0020:        num4 = A_0        num4 *= &H341fbL        num4 += &H267ec1L        A_0 = num4        num4 = num4 >> &H10        num4 = num4 And &H7fffL        num4 = num4 And &HffL        If numArray(CInt(DirectCast(num4, IntPtr))) <> 0 Then            GoTo Label_0020        End If        numArray(CInt(DirectCast(num4, IntPtr))) = 1        Me.j(index) = CByte(num4)        num3 += 1        index += 1        Label_007A:        If num3 < &H100 Then            GoTo Label_0020        End If    NextEnd Sub 

读书人网 >C#

热点推荐