给定一个数列,找到校验位算法...?数列、算法、校验位

2023-09-11 06:23:15 作者:诺言许的快忘的也快

假如我有一系列指标的数字是由校验位。如果我有一个公平的足够的样本(说250样本指数的数字),我有一个方法来提取已被用来生成校验位的算法?

Suppose I have a series of index numbers that consists of a check digit. If I have a fair enough sample (Say 250 sample index numbers), do I have a way to extract the algorithm that has been used to generate the check digit?

我觉得应该有一个纲领性的方法ATLEAST找到一组可能的算法。

I think there should be a programmatic approach atleast to find a set of possible algorithms.

更新:一个索引编号的长度是8位数字,包括校验位

UPDATE: The length of a index number is 8 Digits including the check digit.

推荐答案

没有,不是在一般的情况下,由于数量的可能的算法是远远超过你的想象。 250的样本空间可能不足以做适当的数值分析。

No, not in the general case, since the number of possible algorithms is far more than what you may think. A sample space of 250 may not be enough to do proper numerical analysis.

对于一个极端的例子,假设你的样品都是15位。您会的不的能够可靠地检测算法,如果它改变的行为的那些大于15个字符。

For an extreme example, let's say your samples are all 15 digits long. You would not be able to reliably detect the algorithm if it changed the behaviour for those greater than 15 characters.

如果你想可以肯定,你应该反向工程code,检查数字的有效性(如果有的话)。

If you wanted to be sure, you should reverse engineer the code that checks the numbers for validity (if available).

如果您知道该算法是从比一切可能的算法的一个较小的子集绘制,那么它可能是可能的。但算法可能只说对了一半 - 另外还有一个情况下,乘法器,求幂和环绕式甚至使用相同的算法点更改

If you know that the algorithm is drawn from a smaller subset than "every possible algorithm", then it might be possible. But algorithms may be only half the story - there's also the case where multipliers, exponentiation and wrap-around points change even using the same algorithm.