-
-
Save Igvir/6652eaf6c1e5832e2ae4d3d1d12146a0 to your computer and use it in GitHub Desktop.
DiggestFile
This file contains 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
//New file input stream for reading the file content | |
FileInputStream fis = new FileInputStream(file); | |
//Create byte array to read data in chunks | |
byte[] byteArray = new byte[1024]; | |
int bytesCount = 0; | |
//Read file data and update in message digest | |
while ((bytesCount = fis.read(byteArray)) != -1) { | |
digest.update(byteArray, 0, bytesCount); | |
}; | |
//close the stream; We don't need it now. | |
fis.close(); | |
//Get the hash's bytes | |
byte[] bytes = digest.digest(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment