I wanted to do MD5 check when I download file from GCS. However, it seems that I didn't get the correct MD5 my on side..... One example s that got :
local 1B2M2Y8AsgTpgAmY7PhCfg==, cloud JWSLJAR+M3krp1RiOAJzOw==
But I'm pretty sure the file isn't corrupted...
The following code are with C#7.0, using System.Security.Cryptography;
using (var memStream = new MemoryStream())
{
_StorageClient.DownloadObject(bucketName, gcsObj.Name, memStream);
try
{
using (var md5 = MD5.Create())
{
var hash = md5.ComputeHash(memStream);
localMd5 = Convert.ToBase64String(hash);
}
Console.WriteLine($"local {localMd5}, cloud {gcsObj.Md5Hash}");
}
catch
{
Console.WriteLine("Error getting md5 checksum");
}
}
Another question is: the c# lib that I tried to get the CRC32C value of a file only return an uint type, but the GCS object's Crc32C value is a string. How to compare them?