diff --git a/MD5Context.cs b/MD5Context.cs index 5862bfd87..985a5a0d3 100644 --- a/MD5Context.cs +++ b/MD5Context.cs @@ -74,6 +74,9 @@ public sealed class Md5Context : IChecksum _provider.TransformFinalBlock(Array.Empty(), 0, 0); var md5Output = new StringBuilder(); + if(_provider.Hash is null) + return null; + foreach(byte h in _provider.Hash) md5Output.Append(h.ToString("x2")); diff --git a/SHA1Context.cs b/SHA1Context.cs index f332b9b7e..ccb360a5e 100644 --- a/SHA1Context.cs +++ b/SHA1Context.cs @@ -74,6 +74,9 @@ public sealed class Sha1Context : IChecksum _provider.TransformFinalBlock(Array.Empty(), 0, 0); var sha1Output = new StringBuilder(); + if(_provider.Hash is null) + return null; + foreach(byte h in _provider.Hash) sha1Output.Append(h.ToString("x2")); diff --git a/SHA256Context.cs b/SHA256Context.cs index 1e7e49d90..be65193e3 100644 --- a/SHA256Context.cs +++ b/SHA256Context.cs @@ -74,6 +74,9 @@ public sealed class Sha256Context : IChecksum _provider.TransformFinalBlock(Array.Empty(), 0, 0); var sha256Output = new StringBuilder(); + if(_provider.Hash is null) + return null; + foreach(byte h in _provider.Hash) sha256Output.Append(h.ToString("x2")); diff --git a/SHA384Context.cs b/SHA384Context.cs index 12e397f77..26601c78b 100644 --- a/SHA384Context.cs +++ b/SHA384Context.cs @@ -74,6 +74,9 @@ public sealed class Sha384Context : IChecksum _provider.TransformFinalBlock(Array.Empty(), 0, 0); var sha384Output = new StringBuilder(); + if(_provider.Hash is null) + return null; + foreach(byte h in _provider.Hash) sha384Output.Append(h.ToString("x2")); diff --git a/SHA512Context.cs b/SHA512Context.cs index 44098225d..8dbe6fa22 100644 --- a/SHA512Context.cs +++ b/SHA512Context.cs @@ -74,6 +74,9 @@ public sealed class Sha512Context : IChecksum _provider.TransformFinalBlock(Array.Empty(), 0, 0); var sha512Output = new StringBuilder(); + if(_provider.Hash is null) + return null; + foreach(byte h in _provider.Hash) sha512Output.Append(h.ToString("x2"));