Calculate SHA3-256 digest of a file prefixed with shared secret

364 Views Asked by At

I am using the following code to compute the message digest of a file -
in points to a file here

        bytesRead = in.read(inputBuffer);

         md= MessageDigest.getInstance("SHA3-256");
    while (bytesRead > 0) {
                md.update(inputBuffer, 0, bytesRead);
                    bytesRead = in.read(inputBuffer);
}

Now my aim is to calculate the digest of a file prefixed with a shared secret = hello world
I am not sure if message digest provides any special methods to include a shared secret
I explored the PBEKEYSpec class but that seems to be having a different purpose for passwords etc.
One option to achieve this could be simply to take the shared secret and put it in front of the file and compute the digest. Will that be a good approach? Any other better approach?

0

There are 0 best solutions below