mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Hashing
This commit is contained in:
@@ -13,6 +13,7 @@ namespace SabreTools.Library.DatItems
|
||||
#region Private instance variables
|
||||
|
||||
private byte[] _md5; // 16 bytes
|
||||
private byte[] _ripemd160; // 20 bytes
|
||||
private byte[] _sha1; // 20 bytes
|
||||
private byte[] _sha256; // 32 bytes
|
||||
private byte[] _sha384; // 48 bytes
|
||||
@@ -31,6 +32,15 @@ namespace SabreTools.Library.DatItems
|
||||
set { _md5 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Data RIPEMD160 hash
|
||||
/// </summary>
|
||||
public string RIPEMD160
|
||||
{
|
||||
get { return _ripemd160.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_ripemd160); }
|
||||
set { _ripemd160 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Data SHA-1 hash
|
||||
/// </summary>
|
||||
@@ -120,6 +130,7 @@ namespace SabreTools.Library.DatItems
|
||||
{
|
||||
this.Name = baseFile.Filename;
|
||||
_md5 = baseFile.MD5;
|
||||
_ripemd160 = baseFile.RIPEMD160;
|
||||
_sha1 = baseFile.SHA1;
|
||||
_sha256 = baseFile.SHA256;
|
||||
_sha384 = baseFile.SHA384;
|
||||
@@ -172,6 +183,7 @@ namespace SabreTools.Library.DatItems
|
||||
Source = this.Source,
|
||||
|
||||
_md5 = this._md5,
|
||||
_ripemd160 = this._ripemd160,
|
||||
_sha1 = this._sha1,
|
||||
_sha256 = this._sha256,
|
||||
_sha384 = this._sha384,
|
||||
@@ -194,6 +206,7 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
CRC = null,
|
||||
MD5 = this.MD5,
|
||||
RIPEMD160 = this.RIPEMD160,
|
||||
SHA1 = this.SHA1,
|
||||
SHA256 = this.SHA256,
|
||||
SHA384 = this.SHA384,
|
||||
@@ -260,6 +273,7 @@ namespace SabreTools.Library.DatItems
|
||||
if ((this.ItemStatus == ItemStatus.Nodump && newOther.ItemStatus == ItemStatus.Nodump)
|
||||
&& (this.Name == newOther.Name)
|
||||
&& (this._md5.IsNullOrWhiteSpace() && newOther._md5.IsNullOrWhiteSpace())
|
||||
&& (this._ripemd160.IsNullOrWhiteSpace() && newOther._ripemd160.IsNullOrWhiteSpace())
|
||||
&& (this._sha1.IsNullOrWhiteSpace() && newOther._sha1.IsNullOrWhiteSpace())
|
||||
&& (this._sha256.IsNullOrWhiteSpace() && newOther._sha256.IsNullOrWhiteSpace())
|
||||
&& (this._sha384.IsNullOrWhiteSpace() && newOther._sha384.IsNullOrWhiteSpace())
|
||||
@@ -270,6 +284,7 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
// If we can determine that the disks have no non-empty hashes in common, we return false
|
||||
else if ((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace())
|
||||
&& (this._ripemd160.IsNullOrWhiteSpace() || newOther._ripemd160.IsNullOrWhiteSpace())
|
||||
&& (this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace())
|
||||
&& (this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace())
|
||||
&& (this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace())
|
||||
@@ -280,6 +295,7 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
// Otherwise if we get a partial match
|
||||
else if (((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._md5, newOther._md5))
|
||||
&& ((this._ripemd160.IsNullOrWhiteSpace() || newOther._ripemd160.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._ripemd160, newOther._ripemd160))
|
||||
&& ((this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha1, newOther._sha1))
|
||||
&& ((this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha256, newOther._sha256))
|
||||
&& ((this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha384, newOther._sha384))
|
||||
|
||||
Reference in New Issue
Block a user