gpt4 book ai didi

java - 比较两个 .class 文件的哈希值

转载 作者:行者123 更新时间:2023-12-02 05:58:49 25 4
gpt4 key购买 nike

我发现编译器可以使用相同的 .java 源文件生成不同的 .class 文件。我刚刚尝试使用 Ant 和 Eclipse 编译 .java 文件,结果文件大小不同,这使得这些文件的哈希值不匹配。

使用Ant,我发现生成了一些空的匿名内部类。那么,如何通过哈希值或其他快速方式匹配来自不同编译器的 .class 文件?

注意:如果我将 .class 文件生成为 .java,则哈希值会匹配。这是唯一的方法吗?

最佳答案

So, how can I match the .class files from different compilers via hash value or anything quick?

简而言之,我认为没有简单的方法。不同的编译器很可能从相同的源代码生成不同的字节码。

不过,研究一下文献可能还是值得的。快速 Google 搜索发现了这一点:

A Plagiarism Detection Technique for Java Program Using Bytecode Analysis

Jeong-Hoon Ji, Gyun Woo, Hwan-Gue Cho

ABSTRACT Most plagiarism detection systems evaluate the similarity of source codes and detect plagiarized program pairs. If we use the source codes in plagiarism detection, the source code security can be a significant problem. Plagiarism detection based on target code can be used for protecting the security of source codes. In this paper, we propose anew plagiarism detection technique for Java programs using bytecodes without referring their source codes. The plagiarism detection procedure using bytecode consists of two major steps. First, we generate the token sequences from the Java class file by analyzing the code area of methods. Then, we evaluate the similarity between token sequences using the adaptive local alignment. According to the experimental results, we can find the distributions of similarities of the source codes and that of bytecodes are very similar. Also, the correlation between the similarities of source code pairs and those of bytecode pairs is high enough for typical test data. The plagiarism detection system using bytecode can be used as a preliminary verifying tool before detecting the plagiarism by source code comparison.

还有Deducing Similarities in Java Sources from Bytecodes ,但是用 Java 术语来说它已经非常过时了(1998 年)。不过,可能仍然是一个有值(value)的想法来源。

我确信还有更多文献。这是我在两分钟内找到的。

关于java - 比较两个 .class 文件的哈希值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22846970/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com