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

发布于 2024-08-23 02:04:25 字数 218 浏览 5 评论 0原文

假设我有一系列索引号,其中包含 校验位。如果我有足够公平的样本(比如 250 个样本索引号),我是否有办法提取用于生成校验位的算法?

我认为至少应该有一种编程方法来找到一组可能的算法。

更新:索引号的长度为 8 位,包括校验位。

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?

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

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

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

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

发布评论

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

评论(2

小巷里的女流氓 2024-08-30 02:04:25

不,一般情况下不行,因为可能的算法数量远远超出您的想象。 250 个样本空间可能不足以进行正确的数值分析。

举一个极端的例子,假设您的样本长度均为 15 位。如果算法改变了超过 15 个字符的行为,您将无法可靠地检测到该算法。

如果您想确定,您应该对检查数字有效性的代码进行逆向工程(如果可用)。

如果您知道该算法是从比“每种可能的算法”更小的子集得出的,那么它可能是可能的。但算法可能只是故事的一半 - 即使使用相同的算法,乘法器、指数和环绕点也会发生变化。

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.

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.

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.

半山落雨半山空 2024-08-30 02:04:25

paxdiablo 是正确的,如果不做任何其他假设(或者只拥有整个样本空间 - 然后您可以通过查找表定义算法),您就无法猜测该算法。

但是,如果使用某些依赖于“数据位”的线性公式计算校验位(这是一种非常常见的情况,正如您在维基百科文章中看到的那样),则给定足够的样本,您可以使用欧拉消除。

paxdiablo is correct, and you can't guess the algorithm without making any other assumption (or just having the whole sample space - then you can define the algorithm by a look up table).

However, if the check digit is calculated using some linear formula dependent on the "data digits" (which is a very common case, as you can see in the wikipedia article), given enough samples you can use Euler elimination.

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