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

旧时模样 提交于 2019-12-03 02:22:54

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

If I were you I would use the JNI like this guy did and get the speed up that way. This is exactly what the C interface was made for.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!