0

我用反射器反编译了一个 vb.net 应用程序

所有字符串都使用此方法加密:

Public Shared Function smethod_0(ByVal string_0 As String) As String
    Dim length As Integer = string_0.Length
    Dim chArray As Char() = New Char(length  - 1) {}
    Dim i As Integer
    For i = 0 To chArray.Length - 1
        Dim ch As Char = string_0.Chars(i)
        Dim num3 As Byte = CByte((ch Xor (length - i)))
        Dim num4 As Byte = CByte(((ch >> 8) Xor i))
        chArray(i) = DirectCast(((num4 << 8) Or num3), Char)
    Next i
    Return String.Intern(New String(chArray))
End Function

此方法接收如下输入字符串:

"j" & ChrW(354) & ChrW(623) & ChrW(868)

并返回一个可读的字符串。

如何在 vb.net 或 c# 中转换此代码?

Vb.net 编译器抱怨此代码不正确,因为未为 char/int 组合定义 xor。

4

2 回答 2

0

我以这种方式解决了:

    public static string encrypt(string string_0)
    {
        int length = string_0.Length;
        char[] chArray = new char[length];
        for (int i = 0; i < chArray.Length; i++)
        {
            char ch = string_0[i];
            byte num3 = (byte)(ch ^ (length - i));
            byte num4 = (byte)((ch >> 8) ^ i);
            chArray[i] = (char)((num4 << 8) | num3);
        }

        File.AppendAllText("decript.txt", Environment.NewLine + string_0 + "  =  " + string.Intern(new string(chArray)));

return string.Intern(new string(chArray));

    }

感谢帮助

于 2012-06-21T00:39:05.067 回答
0

C# 版本(仅出于教育原因 - 尽可能保留类似的代码):

public static string encrypt(string s)
{
    int length = s.Length, i = 0;
    char[] chArray = new char[length];
    byte b1, b2;
    char ch;
    for (i = 0; i <= chArray.Length - 1; i++)
    {
        ch = s[i];
        b1 = Convert.ToByte((ch ^ (length - i)));
        b2 = Convert.ToByte(((ch >> 8) ^ i));
        chArray[i] = (char)((b2 << 8) | b1);
    }
    return string.Intern(new string(chArray));
}
于 2012-06-20T09:33:03.910 回答