-3

我有一个无符号字符串(这里是十六进制: d3 ea 12 f7 f7 )。现在这个字符串,不知何故转换成整数 37224,我想知道你必须采取的转换步骤

我所知道的,因为它是一个 int,字符串中可能有一个 char 太多了,因为 int 是 4 字节长,而这个字符串是 5 字节,第一个字节或最后一个字节很可能需要被丢弃

它可能被加密或字节被移动或类似的东西?

关于如何找出转换步骤的任何想法?

十六进制的无符号字符字符串:d3 ea 12 f7 f7

int 它转换为:37224

4

1 回答 1

3

I shall elaborate a bit on my comment:

any idea on how u could find out the steps of conversion?

You can't. Well, you can guess, or you can assign one arbitrarily, but knowing the conversion with certainty is not possible. A single output and a single input are meaningless. You might as well just assume the function is:

if (in == 37224) { return "d3 ea 12 f7 f7"; }

There are infinitely many functions such that these two values map to each other. Looking for the 'correct' function is not possible. As I said in the comment, you can guess the function, and if you can find some kind of meaningful pattern, you can probably assume that it's correct. Even if you see an obvious pattern though, with a sample size of one, that could be a dangerous function.

Think of it this way:

f(2) = 4

What is the inverse of the function f? You could guess f^-1(x) = x/2. But, it could also be f^-1(x) = log2(x) (basically either f(x) = 2x or f(x) = 2^x).

The same idea applies here. You can assume that you found the correct inverse function, but you can never know for sure.

g(y) is the inverse of f(x) if and only if for all x in the domain of f, g(f(x)) = x.

Knowing that for one value of x that g(f(x)) = x does not prove that g(y) is the inverse of f(x). (It's basically meaningless knowledge actually [other than it's an intersection of g and f] unless you're willing to take a leap of faith that it is indeed the inverse.)

于 2012-05-18T10:17:57.570 回答