react-native-fs
react-native-fs copied to clipboard
How to calculate identical hashes in React Native and Node?
I'm using hash to generate checksums for files before I upload them to AWS S3.
RNFS.hash(localUrl, "md5")
This seems to work great. Once the file has been uploaded, I need to verify the checksum for the file using Node 10.x (Lambda). I can't seem to get the same checksum using other libraries. For example, with Node's crypto.createHash:
const file = await s3
.getObject({
Bucket,
Key
}).promise()
crypto
.createHash("md5")
.update(file.Body)
.digest("hex");
The generated hash does not match what was produced by react-native-fs. How do I generate a hash in Node identical to what is produced by react-native-fs for the same file?
Hi @joebernard have you find any solution for the same.I am also facing same issue in IOS md5 hash is differ from aws md5 hash.
@prashantm8 No I was never able to find a good solution for this. Please post if you discover one.
@prashantm8 No I was never able to find a good solution for this. Please post if you discover one.
Then could you please tell me any work around. I am trying to send file on aws with presigned url. Since its a private bucket we have tocalculate checksum. But this checksum is not matching with aws checksum only on Ios.
react-native-fs hash method seems to work correctly. There might be a problem with the way you are picking the file in React Native.