Here you can find the source of shaFile(String paramString)
public static String shaFile(String paramString)
//package com.java2s; //License from project: Open Source License import java.io.FileInputStream; import java.security.MessageDigest; public class Main { private static final char[] HEX_DIGITS = { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102 }; public static String shaFile(String paramString) { byte[] arrayOfByte = new byte[1024]; try {/*from w w w . j a v a 2s .c o m*/ FileInputStream localFileInputStream = new FileInputStream( paramString); MessageDigest localMessageDigest = MessageDigest .getInstance("SHA-1"); while (true) { int i = localFileInputStream.read(arrayOfByte); if (i <= 0) { localFileInputStream.close(); return toHexString(localMessageDigest.digest()); } localMessageDigest.update(arrayOfByte, 0, i); } } catch (Exception localException) { } return ""; } public static String toHexString(byte[] paramArrayOfByte) { if (paramArrayOfByte == null) return ""; StringBuilder localStringBuilder = new StringBuilder( paramArrayOfByte.length << 1); for (int i = 0;; i++) { if (i >= paramArrayOfByte.length) return localStringBuilder.toString(); localStringBuilder .append(HEX_DIGITS[((0xF0 & paramArrayOfByte[i]) >>> 4)]); localStringBuilder .append(HEX_DIGITS[(0xF & paramArrayOfByte[i])]); } } }