如何生成Aho-Corasick散列



我最近开始开发一个开源的防病毒软件,尽管哈希是用Aho-Corasick算法生成的。

我很想知道如何从可执行文件生成Aho-Corasick散列,因为我在互联网上几乎没有找到关于这个

的任何信息

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)];

最新更新