如何确定使用了哪种编码算法?

发布于 2025-02-07 22:28:55 字数 368 浏览 1 评论 0 原文

我有一个纯文本及其编码的字符串,我想知道哪种编码器/算法用于编码字符串。

纯文本: Hello World
编码文本: 3MZ7HIANVQTIQTIQNXZJYEI+douj1/mycfsbyocsykkkzto =

我知道这与base64有关,但我尝试过它对我不起作用。

编辑: 我有一个像exe这样的记事本,其中写了“ Hello World”然后保存了它。当我在普通记事本中打开文本文件时,它向我展示了“ 3MZ7HIANVQTIQNXZJYEI+DOUJ1/MYCFSBYOCSYKKKZTO =”。当我在EXE中打开同一文件(我写的地方)时,它显示了纯文本“ Hello World”。

I have a plain text and its encoded string, I wanted to know which encoder/algorithm is used to encode the string.

Plain Text: hello world
Encoded Text: 3MZ7hIAnvqtIqnxZJyEi+dOuJ1/myCfsbYOCsYKkZto=

I know it has something to do with base64, but I have tried it not working for me.

Edit:
I have a notepad like exe, in which I wrote "hello world" then saved it. When I open the text file in a normal notepad it shows me "3MZ7hIAnvqtIqnxZJyEi+dOuJ1/myCfsbYOCsYKkZto=". And When I open the same file in the exe (where I wrote), it shows plain text "hello world".

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

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

发布评论

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

评论(1

情感失落者 2025-02-14 22:28:55

关于base64编码的字符串有两个常见的误解/误解:

  1. 在解码base64编码的字符串后,期望获得可读文本,以及以下假设,即编码是不同的,或者base64解码器在结果时不起作用。达到期望

    给定的字符串似乎是base64编码,它仅包含Base64字符集中的字符,并且正确填充了,因此很可能是Base64编码的字符串。 BASE64编码用于编码各种数据,但是一个非常常见的用例是将二进制数据(不可打印或仅显示为“怪异”符号的字符串)中的二进制数据中,易于处理形式。一个典型的用例是基本64编码加密或哈希的结果,这两者都会创建二进制结果。

  2. 期望base64解码是恢复原始的唯一步骤(例如纯文本,密码等)

    如上所述,Base64通常用于编码加密的二进制结果或哈希。仅基本64不是加密,并且(希望)从未用来保护密码或其他机密信息。
    Base64编码中的“ Hello World”是“ AGVSBG8GD29YBGQ =”,每个人都可以用任何密码的过程通常是首先哈希密码,然后base64编码二进制哈希值。有关其他机密信息,它正在加密,然后是Base64编码。


是基本

64编码。典型的后续问题是:
如果我从解码中获得的二进制齿轮是加密或哈希的结果,我该如何获得纯文本?

答案是:可能根本不是,至少不是基于给定信息。

如果是哈希,则没有什么可以解密的,因为哈希是一个单向过程。
如果已加密,则没有信息如何解密此信息。为了解密,您需要知道加密算法和键。

在哈希或加密的情况下,二进制信息通常不包含任何标记数据作为某些哈希或加密算法的结果。
我可以从base64编码的字符串(除二进制结果)中获得的唯一信息是长度。给定的字符串长44个字符,其中包括一个填充字符,即43 * 6(每个base64字符编码6位)= 258位,因此大概256位。例如,这可能是SHA-256哈希,但实际上只是一种可能性。

后来在有关存储base64字符串的程序的问题中添加了段落,并在阅读后检索原始数据
使Base64字符串可能包含加密信息,但这就是我可以从中获得的。

There are two common misunderstandings/misconceptions regarding base64 encoded strings:

  1. The expectation to get readable text after decoding a base64 encoded string, along with the assumption that either the encoding is different or the base64 decoder doesn't work when the result doesn't meet the expectation

    The given string seems to be base64 encoded, it only contains characters from the base64 character set and it is correctly padded, so it's very likely a base64 encoded string. Base64 encoding is used to encode all kinds of data, but a very common use case is to encode binary data (that would not be printable or only shown as a string of 'weird`' symbols) into an easier to handle form. One typical use case is to base64 encode the result of encryption or hashing, which both create binary results.

  2. The expectation that base64 decoding is the only step necessary to get back the original (e.g. plain text, password, etc.)

    As mentioned above, base64 is often used to encode the binary result of encryption or hashing. Base64 alone is not encryption and (hopefully) never used to secure passwords or other confidential information.
    "hello world" in base64 encoding is "aGVsbG8gd29ybGQ=", and everyone can decode it with any base64 decoder.
    The process for passwords is usually to first hash the password and then base64 encode the binary hash value. For other confidential information it's encrypting and then base64 encoding.

Having said this, the conclusion is that the given string is likely a base64 encoded hash or encrypted text.

The typical follow up question is:
If this binary gibberish that I get from decoding is the result of encryption or hashing, how do I get the plain text?

The answer for this is: probably not at all, at least not based on the given information.

If it's a hash, there is nothing to decrypt as hashing is a one-way process.
If it's encrypted, there is no information how to decrypt this. For decryption you would need to know the encryption algorithm and the key.

And in case of hashing or encryption, the binary information usually doesn't contain any marker that marks the data as being the result of any certain hashing or encryption algorithm.
The only information I can get from the base64 encoded string (aside from the binary result) is the length. The given string is 44 characters long including one padding character, that's 43 * 6 (every base64 character encodes 6 bits) = 258 bits, so probably 256 bits. That could be, for example, a sha-256 hash, but really just a possibility.

The later added paragraph in the question about the program that stores the base64 string and retrieves the original data after reading it
makes it likely that the base64 string contains encrypted information, but that's all I can get from it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文