Use Array.Empty<T>.

This commit is contained in:
2021-08-17 18:21:11 +01:00
parent dbf3a01f43
commit da3cbf28f4
5 changed files with 15 additions and 10 deletions

View File

@@ -30,6 +30,7 @@
// Copyright © 2011-2021 Natalia Portillo // Copyright © 2011-2021 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
using System;
using System.IO; using System.IO;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
@@ -60,7 +61,7 @@ namespace Aaru.Checksums
/// <summary>Returns a byte array of the hash value.</summary> /// <summary>Returns a byte array of the hash value.</summary>
public byte[] Final() public byte[] Final()
{ {
_provider.TransformFinalBlock(new byte[0], 0, 0); _provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
return _provider.Hash; return _provider.Hash;
} }
@@ -69,7 +70,7 @@ namespace Aaru.Checksums
/// <summary>Returns a hexadecimal representation of the hash value.</summary> /// <summary>Returns a hexadecimal representation of the hash value.</summary>
public string End() public string End()
{ {
_provider.TransformFinalBlock(new byte[0], 0, 0); _provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
var md5Output = new StringBuilder(); var md5Output = new StringBuilder();
foreach(byte h in _provider.Hash) foreach(byte h in _provider.Hash)

View File

@@ -30,6 +30,7 @@
// Copyright © 2011-2021 Natalia Portillo // Copyright © 2011-2021 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
using System;
using System.IO; using System.IO;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
@@ -60,7 +61,7 @@ namespace Aaru.Checksums
/// <summary>Returns a byte array of the hash value.</summary> /// <summary>Returns a byte array of the hash value.</summary>
public byte[] Final() public byte[] Final()
{ {
_provider.TransformFinalBlock(new byte[0], 0, 0); _provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
return _provider.Hash; return _provider.Hash;
} }
@@ -69,7 +70,7 @@ namespace Aaru.Checksums
/// <summary>Returns a hexadecimal representation of the hash value.</summary> /// <summary>Returns a hexadecimal representation of the hash value.</summary>
public string End() public string End()
{ {
_provider.TransformFinalBlock(new byte[0], 0, 0); _provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
var sha1Output = new StringBuilder(); var sha1Output = new StringBuilder();
foreach(byte h in _provider.Hash) foreach(byte h in _provider.Hash)

View File

@@ -30,6 +30,7 @@
// Copyright © 2011-2021 Natalia Portillo // Copyright © 2011-2021 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
using System;
using System.IO; using System.IO;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
@@ -60,7 +61,7 @@ namespace Aaru.Checksums
/// <summary>Returns a byte array of the hash value.</summary> /// <summary>Returns a byte array of the hash value.</summary>
public byte[] Final() public byte[] Final()
{ {
_provider.TransformFinalBlock(new byte[0], 0, 0); _provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
return _provider.Hash; return _provider.Hash;
} }
@@ -69,7 +70,7 @@ namespace Aaru.Checksums
/// <summary>Returns a hexadecimal representation of the hash value.</summary> /// <summary>Returns a hexadecimal representation of the hash value.</summary>
public string End() public string End()
{ {
_provider.TransformFinalBlock(new byte[0], 0, 0); _provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
var sha256Output = new StringBuilder(); var sha256Output = new StringBuilder();
foreach(byte h in _provider.Hash) foreach(byte h in _provider.Hash)

View File

@@ -30,6 +30,7 @@
// Copyright © 2011-2021 Natalia Portillo // Copyright © 2011-2021 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
using System;
using System.IO; using System.IO;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
@@ -60,7 +61,7 @@ namespace Aaru.Checksums
/// <summary>Returns a byte array of the hash value.</summary> /// <summary>Returns a byte array of the hash value.</summary>
public byte[] Final() public byte[] Final()
{ {
_provider.TransformFinalBlock(new byte[0], 0, 0); _provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
return _provider.Hash; return _provider.Hash;
} }
@@ -69,7 +70,7 @@ namespace Aaru.Checksums
/// <summary>Returns a hexadecimal representation of the hash value.</summary> /// <summary>Returns a hexadecimal representation of the hash value.</summary>
public string End() public string End()
{ {
_provider.TransformFinalBlock(new byte[0], 0, 0); _provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
var sha384Output = new StringBuilder(); var sha384Output = new StringBuilder();
foreach(byte h in _provider.Hash) foreach(byte h in _provider.Hash)

View File

@@ -30,6 +30,7 @@
// Copyright © 2011-2021 Natalia Portillo // Copyright © 2011-2021 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
using System;
using System.IO; using System.IO;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
@@ -60,7 +61,7 @@ namespace Aaru.Checksums
/// <summary>Returns a byte array of the hash value.</summary> /// <summary>Returns a byte array of the hash value.</summary>
public byte[] Final() public byte[] Final()
{ {
_provider.TransformFinalBlock(new byte[0], 0, 0); _provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
return _provider.Hash; return _provider.Hash;
} }
@@ -69,7 +70,7 @@ namespace Aaru.Checksums
/// <summary>Returns a hexadecimal representation of the hash value.</summary> /// <summary>Returns a hexadecimal representation of the hash value.</summary>
public string End() public string End()
{ {
_provider.TransformFinalBlock(new byte[0], 0, 0); _provider.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
var sha512Output = new StringBuilder(); var sha512Output = new StringBuilder();
foreach(byte h in _provider.Hash) foreach(byte h in _provider.Hash)