mirror of
https://github.com/aaru-dps/Aaru.Checksums.git
synced 2025-12-16 19:24:29 +00:00
Add null reference checks.
This commit is contained in:
@@ -74,6 +74,9 @@ public sealed class Md5Context : IChecksum
|
|||||||
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
||||||
var md5Output = new StringBuilder();
|
var md5Output = new StringBuilder();
|
||||||
|
|
||||||
|
if(_provider.Hash is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
foreach(byte h in _provider.Hash)
|
foreach(byte h in _provider.Hash)
|
||||||
md5Output.Append(h.ToString("x2"));
|
md5Output.Append(h.ToString("x2"));
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ public sealed class Sha1Context : IChecksum
|
|||||||
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
||||||
var sha1Output = new StringBuilder();
|
var sha1Output = new StringBuilder();
|
||||||
|
|
||||||
|
if(_provider.Hash is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
foreach(byte h in _provider.Hash)
|
foreach(byte h in _provider.Hash)
|
||||||
sha1Output.Append(h.ToString("x2"));
|
sha1Output.Append(h.ToString("x2"));
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ public sealed class Sha256Context : IChecksum
|
|||||||
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
||||||
var sha256Output = new StringBuilder();
|
var sha256Output = new StringBuilder();
|
||||||
|
|
||||||
|
if(_provider.Hash is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
foreach(byte h in _provider.Hash)
|
foreach(byte h in _provider.Hash)
|
||||||
sha256Output.Append(h.ToString("x2"));
|
sha256Output.Append(h.ToString("x2"));
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ public sealed class Sha384Context : IChecksum
|
|||||||
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
||||||
var sha384Output = new StringBuilder();
|
var sha384Output = new StringBuilder();
|
||||||
|
|
||||||
|
if(_provider.Hash is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
foreach(byte h in _provider.Hash)
|
foreach(byte h in _provider.Hash)
|
||||||
sha384Output.Append(h.ToString("x2"));
|
sha384Output.Append(h.ToString("x2"));
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ public sealed class Sha512Context : IChecksum
|
|||||||
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
||||||
var sha512Output = new StringBuilder();
|
var sha512Output = new StringBuilder();
|
||||||
|
|
||||||
|
if(_provider.Hash is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
foreach(byte h in _provider.Hash)
|
foreach(byte h in _provider.Hash)
|
||||||
sha512Output.Append(h.ToString("x2"));
|
sha512Output.Append(h.ToString("x2"));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user