Android, calculating SHA-1 hash from file, fastest algorithm

前端 未结 2 839
予麋鹿
予麋鹿 2021-02-05 17:58

I have a problem with SHA-1 performance on Android. In C# I get calculated hash in about 3s, same calculation for Android takes about 75s. I think the problem is in reading oper

2条回答
  •  长发绾君心
    2021-02-05 18:19

    I tested it on my SGS (i9000) and it took 0.806s to generate the hash for a 10.1MB file.

    Only difference is that in my code i am using BufferedInputStream in addition to the FileInputStream and the hex conversion library found at:

    http://apachejava.blogspot.com/2011/02/hexconversions-convert-string-byte-byte.html

    Also I would suggest that you close your file input stream in a finally clause

提交回复
热议问题