What is the best way to create a SHA-1 for a very large file in pure Java6? How to implement this method:
public abstract String createSha1(java.io.File file);
What is the best way to create a SHA-1 for a very large file in pure Java6? How to implement this method:
public abstract String createSha1(java.io.File file);
Use the
MessageDigest
class and supply data piece by piece. The example below ignores details like turning byte[] into string and closing the file, but should give you the general idea.Op requested the function to return a String of the SHA1, so I took @jeffs answer and added the missing conversion to String: