diff --git a/Adler32Context.cs b/Adler32Context.cs index 00b8400..9c11c16 100644 --- a/Adler32Context.cs +++ b/Adler32Context.cs @@ -49,6 +49,7 @@ namespace Aaru.Checksums sum2 = 0; } + /// /// Updates the hash with data. /// Data buffer. /// Length of buffer to hash. @@ -61,10 +62,12 @@ namespace Aaru.Checksums } } + /// /// Updates the hash with data. /// Data buffer. public void Update(byte[] data) => Update(data, (uint)data.Length); + /// /// Returns a byte array of the hash value. public byte[] Final() { @@ -73,6 +76,7 @@ namespace Aaru.Checksums return BigEndianBitConverter.GetBytes(finalSum); } + /// /// Returns a hexadecimal representation of the hash value. public string End() { diff --git a/CDChecksums.cs b/CDChecksums.cs index c665ef5..9ad468a 100644 --- a/CDChecksums.cs +++ b/CDChecksums.cs @@ -410,86 +410,70 @@ namespace Aaru.Checksums for(int j = 0; j < 18; j++) { - if(j < 18) - cdTextPack1[j] = (byte)(cdTextPack1[j] | ((subchannel[i++] & 0x3F) << 2)); + cdTextPack1[j] = (byte)(cdTextPack1[j] | ((subchannel[i++] & 0x3F) << 2)); - if(j < 18) + if(j < 17) cdTextPack1[j] = (byte)(cdTextPack1[j++] | ((subchannel[i] & 0xC0) >> 4)); - if(j < 18) - cdTextPack1[j] = (byte)(cdTextPack1[j] | ((subchannel[i++] & 0x0F) << 4)); + cdTextPack1[j] = (byte)(cdTextPack1[j] | ((subchannel[i++] & 0x0F) << 4)); - if(j < 18) + if(j < 17) cdTextPack1[j] = (byte)(cdTextPack1[j++] | ((subchannel[i] & 0x3C) >> 2)); - if(j < 18) - cdTextPack1[j] = (byte)(cdTextPack1[j] | ((subchannel[i++] & 0x03) << 6)); + cdTextPack1[j] = (byte)(cdTextPack1[j] | ((subchannel[i++] & 0x03) << 6)); - if(j < 18) - cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x3F)); + cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x3F)); } for(int j = 0; j < 18; j++) { - if(j < 18) - cdTextPack2[j] = (byte)(cdTextPack2[j] | ((subchannel[i++] & 0x3F) << 2)); + cdTextPack2[j] = (byte)(cdTextPack2[j] | ((subchannel[i++] & 0x3F) << 2)); - if(j < 18) + if(j < 17) cdTextPack2[j] = (byte)(cdTextPack2[j++] | ((subchannel[i] & 0xC0) >> 4)); - if(j < 18) - cdTextPack2[j] = (byte)(cdTextPack2[j] | ((subchannel[i++] & 0x0F) << 4)); + cdTextPack2[j] = (byte)(cdTextPack2[j] | ((subchannel[i++] & 0x0F) << 4)); - if(j < 18) + if(j < 17) cdTextPack2[j] = (byte)(cdTextPack2[j++] | ((subchannel[i] & 0x3C) >> 2)); - if(j < 18) - cdTextPack2[j] = (byte)(cdTextPack2[j] | ((subchannel[i++] & 0x03) << 6)); + cdTextPack2[j] = (byte)(cdTextPack2[j] | ((subchannel[i++] & 0x03) << 6)); - if(j < 18) - cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x3F)); + cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x3F)); } for(int j = 0; j < 18; j++) { - if(j < 18) - cdTextPack3[j] = (byte)(cdTextPack3[j] | ((subchannel[i++] & 0x3F) << 2)); + cdTextPack3[j] = (byte)(cdTextPack3[j] | ((subchannel[i++] & 0x3F) << 2)); - if(j < 18) + if(j < 17) cdTextPack3[j] = (byte)(cdTextPack3[j++] | ((subchannel[i] & 0xC0) >> 4)); - if(j < 18) - cdTextPack3[j] = (byte)(cdTextPack3[j] | ((subchannel[i++] & 0x0F) << 4)); + cdTextPack3[j] = (byte)(cdTextPack3[j] | ((subchannel[i++] & 0x0F) << 4)); - if(j < 18) + if(j < 17) cdTextPack3[j] = (byte)(cdTextPack3[j++] | ((subchannel[i] & 0x3C) >> 2)); - if(j < 18) - cdTextPack3[j] = (byte)(cdTextPack3[j] | ((subchannel[i++] & 0x03) << 6)); + cdTextPack3[j] = (byte)(cdTextPack3[j] | ((subchannel[i++] & 0x03) << 6)); - if(j < 18) - cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x3F)); + cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x3F)); } for(int j = 0; j < 18; j++) { - if(j < 18) - cdTextPack4[j] = (byte)(cdTextPack4[j] | ((subchannel[i++] & 0x3F) << 2)); + cdTextPack4[j] = (byte)(cdTextPack4[j] | ((subchannel[i++] & 0x3F) << 2)); - if(j < 18) + if(j < 17) cdTextPack4[j] = (byte)(cdTextPack4[j++] | ((subchannel[i] & 0xC0) >> 4)); - if(j < 18) - cdTextPack4[j] = (byte)(cdTextPack4[j] | ((subchannel[i++] & 0x0F) << 4)); + cdTextPack4[j] = (byte)(cdTextPack4[j] | ((subchannel[i++] & 0x0F) << 4)); - if(j < 18) + if(j < 17) cdTextPack4[j] = (byte)(cdTextPack4[j++] | ((subchannel[i] & 0x3C) >> 2)); - if(j < 18) - cdTextPack4[j] = (byte)(cdTextPack4[j] | ((subchannel[i++] & 0x03) << 6)); + cdTextPack4[j] = (byte)(cdTextPack4[j] | ((subchannel[i++] & 0x03) << 6)); - if(j < 18) - cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x3F)); + cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x3F)); } i = 0; diff --git a/CRC16Context.cs b/CRC16Context.cs index b1b449e..eeb4352 100644 --- a/CRC16Context.cs +++ b/CRC16Context.cs @@ -55,6 +55,7 @@ namespace Aaru.Checksums _table = table ?? GenerateTable(polynomial, inverse); } + /// /// Updates the hash with data. /// Data buffer. /// Length of buffer to hash. @@ -69,13 +70,16 @@ namespace Aaru.Checksums } } + /// /// Updates the hash with data. /// Data buffer. public void Update(byte[] data) => Update(data, (uint)data.Length); + /// /// Returns a byte array of the hash value. public byte[] Final() => BigEndianBitConverter.GetBytes((ushort)(_hashInt ^ _finalSeed)); + /// /// Returns a hexadecimal representation of the hash value. public string End() { diff --git a/CRC32Context.cs b/CRC32Context.cs index 3e5ac9a..b29fe1e 100644 --- a/CRC32Context.cs +++ b/CRC32Context.cs @@ -92,6 +92,7 @@ namespace Aaru.Checksums } } + /// /// Updates the hash with data. /// Data buffer. /// Length of buffer to hash. @@ -101,13 +102,16 @@ namespace Aaru.Checksums hashInt = (hashInt >> 8) ^ table[data[i] ^ (hashInt & 0xff)]; } + /// /// Updates the hash with data. /// Data buffer. public void Update(byte[] data) => Update(data, (uint)data.Length); + /// /// Returns a byte array of the hash value. public byte[] Final() => BigEndianBitConverter.GetBytes(hashInt ^ finalSeed); + /// /// Returns a hexadecimal representation of the hash value. public string End() { diff --git a/CRC64Context.cs b/CRC64Context.cs index ca5b6c0..e6a93f7 100644 --- a/CRC64Context.cs +++ b/CRC64Context.cs @@ -92,6 +92,7 @@ namespace Aaru.Checksums finalSeed = seed; } + /// /// Updates the hash with data. /// Data buffer. /// Length of buffer to hash. @@ -101,13 +102,16 @@ namespace Aaru.Checksums hashInt = (hashInt >> 8) ^ table[data[i] ^ (hashInt & 0xff)]; } + /// /// Updates the hash with data. /// Data buffer. public void Update(byte[] data) => Update(data, (uint)data.Length); + /// /// Returns a byte array of the hash value. public byte[] Final() => BigEndianBitConverter.GetBytes(hashInt ^= finalSeed); + /// /// Returns a hexadecimal representation of the hash value. public string End() { diff --git a/FletcherContext.cs b/FletcherContext.cs index 12ab098..d4cb4a8 100644 --- a/FletcherContext.cs +++ b/FletcherContext.cs @@ -51,6 +51,7 @@ namespace Aaru.Checksums sum2 = 0xFFFF; } + /// /// Updates the hash with data. /// Data buffer. /// Length of buffer to hash. @@ -63,10 +64,12 @@ namespace Aaru.Checksums } } + /// /// Updates the hash with data. /// Data buffer. public void Update(byte[] data) => Update(data, (uint)data.Length); + /// /// Returns a byte array of the hash value. public byte[] Final() { @@ -75,6 +78,7 @@ namespace Aaru.Checksums return BigEndianBitConverter.GetBytes(finalSum); } + /// /// Returns a hexadecimal representation of the hash value. public string End() { @@ -172,6 +176,7 @@ namespace Aaru.Checksums sum2 = 0xFF; } + /// /// Updates the hash with data. /// Data buffer. /// Length of buffer to hash. @@ -184,10 +189,12 @@ namespace Aaru.Checksums } } + /// /// Updates the hash with data. /// Data buffer. public void Update(byte[] data) => Update(data, (uint)data.Length); + /// /// Returns a byte array of the hash value. public byte[] Final() { @@ -196,6 +203,7 @@ namespace Aaru.Checksums return BigEndianBitConverter.GetBytes(finalSum); } + /// /// Returns a hexadecimal representation of the hash value. public string End() { diff --git a/MD5Context.cs b/MD5Context.cs index 9abe454..abd4e43 100644 --- a/MD5Context.cs +++ b/MD5Context.cs @@ -45,15 +45,18 @@ namespace Aaru.Checksums /// Initializes the MD5 hash provider public Md5Context() => md5Provider = MD5.Create(); + /// /// Updates the hash with data. /// Data buffer. /// Length of buffer to hash. public void Update(byte[] data, uint len) => md5Provider.TransformBlock(data, 0, (int)len, data, 0); + /// /// Updates the hash with data. /// Data buffer. public void Update(byte[] data) => Update(data, (uint)data.Length); + /// /// Returns a byte array of the hash value. public byte[] Final() { @@ -62,6 +65,7 @@ namespace Aaru.Checksums return md5Provider.Hash; } + /// /// Returns a hexadecimal representation of the hash value. public string End() { diff --git a/SHA1Context.cs b/SHA1Context.cs index 7cf8369..4263ea1 100644 --- a/SHA1Context.cs +++ b/SHA1Context.cs @@ -45,15 +45,18 @@ namespace Aaru.Checksums /// Initializes the SHA1 hash provider public Sha1Context() => sha1Provider = SHA1.Create(); + /// /// Updates the hash with data. /// Data buffer. /// Length of buffer to hash. public void Update(byte[] data, uint len) => sha1Provider.TransformBlock(data, 0, (int)len, data, 0); + /// /// Updates the hash with data. /// Data buffer. public void Update(byte[] data) => Update(data, (uint)data.Length); + /// /// Returns a byte array of the hash value. public byte[] Final() { @@ -62,6 +65,7 @@ namespace Aaru.Checksums return sha1Provider.Hash; } + /// /// Returns a hexadecimal representation of the hash value. public string End() { diff --git a/SHA256Context.cs b/SHA256Context.cs index 49edfb7..c6a98ae 100644 --- a/SHA256Context.cs +++ b/SHA256Context.cs @@ -45,15 +45,18 @@ namespace Aaru.Checksums /// Initializes the SHA256 hash provider public Sha256Context() => sha256Provider = SHA256.Create(); + /// /// Updates the hash with data. /// Data buffer. /// Length of buffer to hash. public void Update(byte[] data, uint len) => sha256Provider.TransformBlock(data, 0, (int)len, data, 0); + /// /// Updates the hash with data. /// Data buffer. public void Update(byte[] data) => Update(data, (uint)data.Length); + /// /// Returns a byte array of the hash value. public byte[] Final() { @@ -62,6 +65,7 @@ namespace Aaru.Checksums return sha256Provider.Hash; } + /// /// Returns a hexadecimal representation of the hash value. public string End() { diff --git a/SHA384Context.cs b/SHA384Context.cs index d4f7cfe..f1d8a9b 100644 --- a/SHA384Context.cs +++ b/SHA384Context.cs @@ -45,15 +45,18 @@ namespace Aaru.Checksums /// Initializes the SHA384 hash provider public Sha384Context() => sha384Provider = SHA384.Create(); + /// /// Updates the hash with data. /// Data buffer. /// Length of buffer to hash. public void Update(byte[] data, uint len) => sha384Provider.TransformBlock(data, 0, (int)len, data, 0); + /// /// Updates the hash with data. /// Data buffer. public void Update(byte[] data) => Update(data, (uint)data.Length); + /// /// Returns a byte array of the hash value. public byte[] Final() { @@ -62,6 +65,7 @@ namespace Aaru.Checksums return sha384Provider.Hash; } + /// /// Returns a hexadecimal representation of the hash value. public string End() { diff --git a/SHA512Context.cs b/SHA512Context.cs index e920f87..c51e1bf 100644 --- a/SHA512Context.cs +++ b/SHA512Context.cs @@ -45,15 +45,18 @@ namespace Aaru.Checksums /// Initializes the SHA512 hash provider public Sha512Context() => sha512Provider = SHA512.Create(); + /// /// Updates the hash with data. /// Data buffer. /// Length of buffer to hash. public void Update(byte[] data, uint len) => sha512Provider.TransformBlock(data, 0, (int)len, data, 0); + /// /// Updates the hash with data. /// Data buffer. public void Update(byte[] data) => Update(data, (uint)data.Length); + /// /// Returns a byte array of the hash value. public byte[] Final() { @@ -62,6 +65,7 @@ namespace Aaru.Checksums return sha512Provider.Hash; } + /// /// Returns a hexadecimal representation of the hash value. public string End() { diff --git a/SpamSumContext.cs b/SpamSumContext.cs index 58973ff..7f409e9 100644 --- a/SpamSumContext.cs +++ b/SpamSumContext.cs @@ -90,6 +90,7 @@ namespace Aaru.Checksums roll_init(); } + /// /// Updates the hash with data. /// Data buffer. /// Length of buffer to hash. @@ -101,13 +102,16 @@ namespace Aaru.Checksums fuzzy_engine_step(data[i]); } + /// /// Updates the hash with data. /// Data buffer. public void Update(byte[] data) => Update(data, (uint)data.Length); + /// /// Returns a byte array of the hash value. public byte[] Final() => throw new NotImplementedException("SpamSum does not have a binary representation."); + /// /// Returns a base64 representation of the hash value. public string End() {