Add null reference checks.

This commit is contained in:
2022-03-17 00:46:25 +00:00
parent 30cbd81c84
commit 01391f7a76
5 changed files with 15 additions and 0 deletions

View File

@@ -74,6 +74,9 @@ public sealed class Md5Context : IChecksum
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
var md5Output = new StringBuilder();
if(_provider.Hash is null)
return null;
foreach(byte h in _provider.Hash)
md5Output.Append(h.ToString("x2"));

View File

@@ -74,6 +74,9 @@ public sealed class Sha1Context : IChecksum
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
var sha1Output = new StringBuilder();
if(_provider.Hash is null)
return null;
foreach(byte h in _provider.Hash)
sha1Output.Append(h.ToString("x2"));

View File

@@ -74,6 +74,9 @@ public sealed class Sha256Context : IChecksum
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
var sha256Output = new StringBuilder();
if(_provider.Hash is null)
return null;
foreach(byte h in _provider.Hash)
sha256Output.Append(h.ToString("x2"));

View File

@@ -74,6 +74,9 @@ public sealed class Sha384Context : IChecksum
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
var sha384Output = new StringBuilder();
if(_provider.Hash is null)
return null;
foreach(byte h in _provider.Hash)
sha384Output.Append(h.ToString("x2"));

View File

@@ -74,6 +74,9 @@ public sealed class Sha512Context : IChecksum
_provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
var sha512Output = new StringBuilder();
if(_provider.Hash is null)
return null;
foreach(byte h in _provider.Hash)
sha512Output.Append(h.ToString("x2"));