本文介绍了如何生成一个阿霍Corasick哈希的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我最近开始开发一个开源的防病毒软件,但都与阿霍Corasick算法生成的哈希值。
I have recently started developing an open source anti virus software, although the hashes are generated with the Aho-Corasick algorithm.
我很想知道如何生成阿霍Corasick的可执行文件哈希,因为我发现几乎没有任何关于这个互联网上的信息
I would love to know how to generate Aho-Corasick hashes from executables, as I have found barely any information on the internet regarding this
推荐答案
在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哈希值
Then you can use, following to get MD5 hash
byte[] bytesOfMessage = readFile("filepath").getBytes("UTF-8");
MessageDigest md = MessageDigest.getInstance("MD5");
String thedigest = Arrays.toString[md.digest(bytesOfMessage)];
这篇关于如何生成一个阿霍Corasick哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!