/// <summary> /// Check the hash value of a specific DG file with the stored hash value in a SOd file. /// </summary> /// <param name="dgFile">DG file from which the hash needs to be checked.</param> /// <param name="sod">SOd file containing the hash for the DG file.</param> /// <returns>True if the hash of the DG file matches the value stored in the SOd file.</returns> public static bool CheckHash(IDGFile dgFile, SODFile sod) { foreach (DataGroupHash hash in sod.GetDataGroupHashes()) { if (hash.DataGroupNumber == dgFile.DataGroupNumber) { SHA256 sha256 = SHA256.Create(); byte[] dgHash = sha256.ComputeHash(dgFile.RawBytes); byte[] sodHash = hash.DataGroupHashValue.GetOctets(); return(Compare(dgHash, sodHash)); } } throw new ArgumentException("Hash of DG" + dgFile.DataGroupNumber + " not found in SOd."); }
/// <summary> /// Check the hash value of a specific DG file with the stored hash value in a SOd file. /// </summary> /// <param name="dgFile">DG file from which the hash needs to be checked.</param> /// <param name="sod">SOd file containing the hash for the DG file.</param> /// <returns>True if the hash of the DG file matches the value stored in the SOd file.</returns> public static bool CheckHash(IDGFile dgFile, SODFile sod) { foreach (DataGroupHash hash in sod.GetDataGroupHashes()) { if (hash.DataGroupNumber == dgFile.DataGroupNumber) { SHA256 sha256 = SHA256.Create(); byte[] dgHash = sha256.ComputeHash(dgFile.RawBytes); byte[] sodHash = hash.DataGroupHashValue.GetOctets(); return Compare(dgHash, sodHash); } } throw new ArgumentException("Hash of DG" + dgFile.DataGroupNumber + " not found in SOd."); }