Reputation: 1
I uploaded a couple of markdowns to an s3 bucket and calculated the md5 hash from them. But now, im double checking if the markdown hash of the downloaded files is the same that the hash calculated previously, and is not.
It seems like the markdown hash that i calculated before upload the file is not the same that the markdown hash that im calculating after download it from the s3 bucket.
The function that im using is:
def get_hash_from_binary(b: bytes) -> str:
return str(uuid.UUID(bytes=hashlib.md5(b).digest()))
This is the piece of code that calculate the first markdown hash:
markdown_text = convert_to_markdown(cleaned_html)
markdown_hash = get_hash_from_binary(markdown_text.encode())
And this is the piece of code that i use to calcule the markdown hash from the downloaded file:
response = s3.get_object(Bucket=BUCKET_NAME, Key=key)
markdown_data = response["Body"].read()
markdown_hash = get_hash_from_binary(markdown_data)
Upvotes: 0
Views: 37