Java: Calculate SHA-256 hash of large file efficiently

前端 未结 7 1528
说谎
说谎 2020-12-13 07:33

I need to calculate a SHA-256 hash of a large file (or portion of it). My implementation works fine, but its much slower than the C++\'s CryptoPP calculation (25 Min. vs. 10

相关标签:
7条回答
  • 2020-12-13 08:18

    It used to be that Java ran about 10x slower than the same C++ code. Nowadays is closer to 2x slower. I think what your running into is just a fundamental part of Java. JVMs will get faster, especially as new JIT techniques are discovered, but you'll have a hard time out performing C.

    Have you tried alternative JVMs and/or compilers? I used to get better performance with JRocket, but less stability. Ditto for using jikes over javac.

    0 讨论(0)
提交回复
热议问题