Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/nes-containers.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2022-11-08 11:20:31 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2022-11-08 11:20:31 +0300
commitae501934ecec1c0323e2b06ca0a020342b4b94b5 (patch)
tree7dcb0abebda5c83896c0e6798e6fc00a01625bf8
parente20a5e0a1d4a26319d3f5ca2004afd6743473f2f (diff)
Minor CRC32 fix
-rw-r--r--Crc32.cs9
-rw-r--r--NesFile.cs2
-rw-r--r--UnifFile.cs2
3 files changed, 5 insertions, 8 deletions
diff --git a/Crc32.cs b/Crc32.cs
index 33acf83..062da30 100644
--- a/Crc32.cs
+++ b/Crc32.cs
@@ -1,4 +1,5 @@
using System;
+using System.Linq;
using System.Security.Cryptography;
namespace com.clusterrr.Famicom.Containers
@@ -52,13 +53,9 @@ namespace com.clusterrr.Famicom.Containers
}
}
- protected override byte[] HashFinal()
- {
- return BitConverter.GetBytes(~crc);
- }
-
+ protected override byte[] HashFinal() => BitConverter.GetBytes(~crc).Reverse().ToArray();
public override bool CanTransformMultipleBlocks => true;
- public override byte[] Hash => BitConverter.GetBytes(~crc);
+ public override byte[] Hash => BitConverter.GetBytes(~crc).Reverse().ToArray();
public override int HashSize => 32;
}
diff --git a/NesFile.cs b/NesFile.cs
index ad45117..1c7bee0 100644
--- a/NesFile.cs
+++ b/NesFile.cs
@@ -969,7 +969,7 @@ namespace com.clusterrr.Famicom.Containers
crc32.TransformBlock(chr, 0, chr.Length, null, 0);
crc32.TransformBlock(Enumerable.Repeat<byte>(byte.MaxValue, chrSizeUpPow2 - chr.Length).ToArray(), 0, chrSizeUpPow2 - chr.Length, null, 0);
crc32.TransformFinalBlock(new byte[0], 0, 0);
- return BitConverter.ToUInt32(crc32.Hash, 0);
+ return BitConverter.ToUInt32(crc32.Hash.Reverse().ToArray(), 0);
}
}
}
diff --git a/UnifFile.cs b/UnifFile.cs
index 0a0f33c..2921b71 100644
--- a/UnifFile.cs
+++ b/UnifFile.cs
@@ -668,7 +668,7 @@ namespace com.clusterrr.Famicom.Containers
crc32.TransformBlock(Enumerable.Repeat<byte>(byte.MaxValue, sizeUpPow2 - v.Length).ToArray(), 0, sizeUpPow2 - v.Length, null, 0);
}
crc32.TransformFinalBlock(new byte[0], 0, 0);
- return BitConverter.ToUInt32(crc32.Hash, 0);
+ return BitConverter.ToUInt32(crc32.Hash.Reverse().ToArray(), 0);
}
/// <summary>