I am generating the SHA1 key in both PHP and Android to verify the file. But I am getting different keys for both PHP and Android.
Android :
try {
MessageDigest digest = MessageDigest.getInstance("SHA-1");
byte[] buffer = new byte[65536];
InputStream fis = new FileInputStream(downloadFile.getPath());
int n = 0;
while (n != -1) {
n = fis.read(buffer);
if (n > 0) {
digest.update(buffer, 0, n);
}
}
fis.close();
byte[] digestResult = digest.digest();
log("CheckSum : " + byteArray2Hex(digestResult));
} catch (Exception e) {
log("Exception : " + e.getLocalizedMessage());
}
PHP:
echo ' \nSHA1 File hash of '. $filePath . ': ' . sha1_file($filePath);
Checksum Output:
PHP SHA1 CheckSum : e7a91cd4127149a230f3dcb5ae81605615d3e1be Android SHA1 CheckSum : 19bcbd9d18a3880d2375bddb9181d75da3f32da0
Can anyone help how to handle this.