Hashing multiple byte[]'s together into a single hash with C#?

前端 未结 6 1078
生来不讨喜
生来不讨喜 2020-12-16 17:54

I have three fields: string Title, byte[] Body, and byte[] Data, from which I want to calculate a single hash as a check to be sure th

6条回答
  •  萌比男神i
    2020-12-16 18:27

    There is also solution in .Net Standard and .Net Core using IncrementalHash

    IncrementalHash md5 = IncrementalHash.Create(HashAlgorithmName.MD5)
    
    // For each block:
    md5.AppendData(block);
    
    // Get the hash code
    byte[] hash = md5.GetHashAndReset();
    

提交回复
热议问题