How to validate CRC32C in C#, as part of Header while sending to Google cloud storage API along with signedUrl?

57 Views Asked by At

I am trying to send x-goog-hash along with crc32c value in header. I am also sending signedUrl has part of requestUri. Even When I passed crc32c value which was generated with same file earlier as part of header, it still returns 400 or

<?xml version='1.0' encoding='UTF-8'?><Error><Code>MalformedSecurityHeader</Code><Message>Invalid argument.</Message><Details>Your request has a malformed header. Header must be signed.</Details><ParameterName>x-goog-hash</ParameterName></Error>

I added CRC32C value as header.

content.Headers.Add("x-goog-hash", "crc32c=ge5pug==");

Earlier I used Crc32CAlgorithm.Compute, I was able to get computed value but still don't know much how to encode that coz if I try Convert.ToBase64String it was giving different value.

I tried two things.

  1. I tried passing CRC32C directly as Header but getting MalformedSecurityHeader error.
  2. How to encode CRC32C computed value? I am using CRC32C.NET package by Force.
0

There are 0 best solutions below