/// <summary> /// Throws a DataCorruptionException if the content hash is available but doesn't match. /// </summary> /// <param name="blob">Cloud Blob</param> /// <param name="fileName">File name</param> public void VerifyContentMd5Hash(ICloudBlob blob, string fileName) { if (blob == null) { throw new ArgumentNullException(nameof(blob)); } if (string.IsNullOrWhiteSpace(fileName)) { throw new ArgumentNullException(nameof(fileName)); } var expectedHash = GetBlobHash(blob); if (string.IsNullOrWhiteSpace(expectedHash)) { throw new DataCorruptionException($"Blob MD5 content hash is null or empty {blob?.Name}. Data is corrupted!"); } var computedHash = _cryptographyHelper.ComputeFileMd5Hash(fileName); if (expectedHash != computedHash) { throw new DataCorruptionException($"Blob MD5 content hash mismatch {fileName}. Data is corrupted! Expected hash: {expectedHash}, computed: {computedHash}"); } }