我最近开始开发一个开源的反病毒软件,尽管散列是用Aho-Corasick算法生成的。
我很想知道如何从可执行文件中生成Aho-Corasick散列,因为我在互联网上几乎没有找到任何关于这方面的信息。
发布于 2011-04-09 07:08:28
在Java中:
private static String readFile(String path) throws IOException {
FileInputStream stream = new FileInputStream(new File(path));
try {
FileChannel fc = stream.getChannel();
MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
/* Instead of using default, pass in a decoder. */
return Charset.defaultCharset().decode(bb).toString();
}
finally {
stream.close();
}
}然后,您可以使用下面的命令来获取MD5散列
byte[] bytesOfMessage = readFile("filepath").getBytes("UTF-8");
MessageDigest md = MessageDigest.getInstance("MD5");
String thedigest = Arrays.toString[md.digest(bytesOfMessage)];https://stackoverflow.com/questions/5601531
复制相似问题