如何解码 Base64 编码的字符串?

发布于 2024-11-30 17:52:18 字数 1485 浏览 0 评论 0原文

我正在尝试“解码”以下 Base64 字符串:

OBFZDTcPCxlCKhdXCQ0kMQhKPh9uIgYIAQxALBtZAwUeOzcdcUEeW0dMO1kbPElWCV1ISFFKZ0kdWFlAURPZhEFQV seXVtPOUUICVhMAzcfZ14AVEdIVVgfAUIBWVpOUlAeaUVMXFlKIy9rGUN0VF08Oz1POxFfTCcVFw1LMQNbBQYWAQ==

这是我对字符串本身的了解:

  1. 原始字符串首先通过以下代码传递:

    私有静态字符串 m000493(字符串 p0, 字符串 p1)
    {
        StringBuilder 构建器 = new StringBuilder(p0);
        StringBuilder builder2 = new StringBuilder(p1);
        StringBuilder builder3 = new StringBuilder(p0.Length);
        整数数=0;
    标签_0084:
        while (num < builder.Length)
        {
            整数 num2 = 0;
            while (num2 < p1.Length)
            {
                if ((num == builder.Length) || (num2 == builder2.Length))
                {
                    MessageBox.Show("呃?");
                    转到标签_0084;
                }
                char ch = 构建器[编号];
                char ch2 = builder2[num2];
                ch = (char)(ch ^ ch2);
                builder3.Append(ch);
                num2++;
                数++;
            }
        }
        返回 m0001cd(builder3.ToString());
    }
    

    代码中的p1部分应该是字符串“_p0lizei.”。

  2. 然后通过以下代码将其转换为 Base64 字符串:

    私有静态字符串 m0001cd(字符串 p0)
    {
        字符串str2;
        尝试
        {
            byte[] 缓冲区 = 新字节[p0.Length];
            str2 = Convert.ToBase64String(Encoding.UTF8.GetBytes(p0));
        }
        catch(异常异常)
        {
            抛出新的异常(“base64Encode 错误”+Exception.Message);
        }
        返回str2;
    }
    

问题是,如何解码 Base64 字符串以便找出原始字符串是什么?

I am trying to "decode" this following Base64 string:

OBFZDTcPCxlCKhdXCQ0kMQhKPh9uIgYIAQxALBtZAwUeOzcdcUEeW0dMO1kbPElWCV1ISFFKZ0kdWFlLAURPZhEFQVseXVtPOUUICVhMAzcfZ14AVEdIVVgfAUIBWVpOUlAeaUVMXFlKIy9rGUN0VF08Oz1POxFfTCcVFw1LMQNbBQYWAQ==

This is what I know about the string itself:

  1. The original string is first passed through the following code:

    private static string m000493(string p0, string p1)
    {
        StringBuilder builder = new StringBuilder(p0);
        StringBuilder builder2 = new StringBuilder(p1);
        StringBuilder builder3 = new StringBuilder(p0.Length);
        int num = 0;
    Label_0084:
        while (num < builder.Length)
        {
            int num2 = 0;
            while (num2 < p1.Length)
            {
                if ((num == builder.Length) || (num2 == builder2.Length))
                {
                    MessageBox.Show("EH?");
                    goto Label_0084;
                }
                char ch = builder[num];
                char ch2 = builder2[num2];
                ch = (char)(ch ^ ch2);
                builder3.Append(ch);
                num2++;
                num++;
            }
        }
        return m0001cd(builder3.ToString());
    }
    

    The p1 part in the code is supposed to be the string "_p0lizei.".

  2. It is then converted to a Base64 string by the following code:

    private static string m0001cd(string p0)
    {
        string str2;
        try
        {
            byte[] buffer = new byte[p0.Length];
            str2 = Convert.ToBase64String(Encoding.UTF8.GetBytes(p0));
        }
        catch (Exception exception)
        {
            throw new Exception("Error in base64Encode" + exception.Message);
        }
        return str2;
    }
    

The question is, how do I decode the Base64 string so that I can find out what the original string is?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

-残月青衣踏尘吟 2024-12-07 17:52:18

简单的:

byte[] data = Convert.FromBase64String(encodedString);
string decodedString = System.Text.Encoding.UTF8.GetString(data);

Simple:

byte[] data = Convert.FromBase64String(encodedString);
string decodedString = System.Text.Encoding.UTF8.GetString(data);
关于从前 2024-12-07 17:52:18

m000493 方法似乎执行某种 XOR 加密。这意味着可以使用相同的方法对文本进行编码和解码。您所要做的就是反转 m0001cd

string p0 = Encoding.UTF8.GetString(Convert.FromBase64String("OBFZDT..."));

string result = m000493(p0, "_p0lizei.");
//    result == "gaia^unplugged^Ta..."

return m0001cd(builder3.ToString()); 更改为 return builder3.ToString();

The m000493 method seems to perform some kind of XOR encryption. This means that the same method can be used for both encoding and decoding the text. All you have to do is reverse m0001cd:

string p0 = Encoding.UTF8.GetString(Convert.FromBase64String("OBFZDT..."));

string result = m000493(p0, "_p0lizei.");
//    result == "gaia^unplugged^Ta..."

with return m0001cd(builder3.ToString()); changed to return builder3.ToString();.

逆光下的微笑 2024-12-07 17:52:18
    // Decode a Base64 string to a string
    public static string DecodeBase64(string value)
    {
        if(string.IsNullOrEmpty(value))
            return string.Empty;
        var valueBytes = System.Convert.FromBase64String(value);
        return System.Text.Encoding.UTF8.GetString(valueBytes);
    }
    // Decode a Base64 string to a string
    public static string DecodeBase64(string value)
    {
        if(string.IsNullOrEmpty(value))
            return string.Empty;
        var valueBytes = System.Convert.FromBase64String(value);
        return System.Text.Encoding.UTF8.GetString(valueBytes);
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文