Created
January 12, 2018 03:06
-
-
Save Porama6400/7285399ab42c8d735202a2ac7b612f0c to your computer and use it in GitHub Desktop.
A method to checksum a file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static String checksum(File file) throws IOException, NoSuchAlgorithmException { | |
| MessageDigest digest = MessageDigest.getInstance("SHA-256"); | |
| BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file)); | |
| byte[] buff = new byte[bis.available()]; | |
| bis.read(buff, 0, buff.length); | |
| byte[] hash = digest.digest(buff); | |
| return new BASE64Encoder().encode(hash); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment