I am trying to hash the content(bytes without the meta information) of an image file in my React native mobile app and React web app. I am using expo-crypto to hash the image in the mobile version and CryptoJS in the web app version. But the hash generated by both these methods are not same.
Can someone please help me figure out where there is a hash mismatch.
RN Expo code
'''
let info = await FileSystem.readAsStringAsync(path);
var digest ;
if(info)
{ digest = await Crypto.digestStringAsync(
Crypto.CryptoDigestAlgorithm.SHA256,
info
);) }
'''
React Code
'''
function handleUpload(event) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = (event) => {
resolve(event.target.result);
var hash = sha256(event.target.result)
};
reader.onerror = (err) => {
reject(err);
};
reader.readAsBinaryString(event.target.files[0]);
}); }
'''