How to generate MD5 with the binary contents of file

My question:
While uploading a file , a MD5 hash is generated with the binary contents of the file and this MD5 is sent to server to obtain a token. With this token actually file upload happens.

How do I generate MD5 with the binary of the file. I am using CryptoJS.MD5(binary).toString(); to get the MD5 hash in Pre request script. However i am unable to figure out how to pass the binary content of the file.

Hi @jayajaya,

Once you have generated the MDS hash from the contents in the pre-requisite script. You can assign the value to the global or environment variable and use the same in body of the request, which will reflect.

Hope this helps :slight_smile:

Hi @pranavdavar , thanks for your response . My questions is I have a file I would like to generate MD5 with the contents of the file. How do i do it?

Thanks
Jayashree

Hi @jayajaya,

You can try using base64 encoded binary content of the file and then pass it by decoding as input to CryptoJS.MD5(binary). By this, you will be able to generate the MD5 token.

Hi @pranavdavar ,
I have to dynamically do it for different files instead of just passing base64 encoded binary content of the file into a variable. Do you have an idea of how it can be done ?

Thanks
Jayashree