SHA1.HashData Method

Definition

Overloads

HashData(Byte[])

Computes the hash of data using the SHA1 algorithm.

HashData(Stream)

Computes the hash of a stream using the SHA1 algorithm.

HashData(ReadOnlySpan<Byte>)

Computes the hash of data using the SHA1 algorithm.

HashData(Stream, Span<Byte>)

Computes the hash of a stream using the SHA1 algorithm.

HashData(ReadOnlySpan<Byte>, Span<Byte>)

Computes the hash of data using the SHA1 algorithm.

HashData(Byte[])

Source:
SHA1.cs
Source:
SHA1.cs
Source:
SHA1.cs

Computes the hash of data using the SHA1 algorithm.

C#
public static byte[] HashData(byte[] source);

Parameters

source
Byte[]

The data to hash.

Returns

Byte[]

The hash of the data.

Exceptions

source is null.

Applies to

.NET 10 and other versions
Product Versions
.NET 5, 6, 7, 8, 9, 10

HashData(Stream)

Source:
SHA1.cs
Source:
SHA1.cs
Source:
SHA1.cs

Computes the hash of a stream using the SHA1 algorithm.

C#
public static byte[] HashData(System.IO.Stream source);

Parameters

source
Stream

The stream to hash.

Returns

Byte[]

The hash of the data.

Exceptions

source is null.

source does not support reading.

Applies to

.NET 10 and other versions
Product Versions
.NET 7, 8, 9, 10

HashData(ReadOnlySpan<Byte>)

Source:
SHA1.cs
Source:
SHA1.cs
Source:
SHA1.cs

Computes the hash of data using the SHA1 algorithm.

C#
public static byte[] HashData(ReadOnlySpan<byte> source);

Parameters

source
ReadOnlySpan<Byte>

The data to hash.

Returns

Byte[]

The hash of the data.

Applies to

.NET 10 and other versions
Product Versions
.NET 5, 6, 7, 8, 9, 10

HashData(Stream, Span<Byte>)

Source:
SHA1.cs
Source:
SHA1.cs
Source:
SHA1.cs

Computes the hash of a stream using the SHA1 algorithm.

C#
public static int HashData(System.IO.Stream source, Span<byte> destination);

Parameters

source
Stream

The stream to hash.

destination
Span<Byte>

The buffer to receive the hash value.

Returns

The total number of bytes written to destination.

Exceptions

source is null.

The buffer in destination is too small to hold the calculated hash size. The SHA1 algorithm always produces a 160-bit hash, or 20 bytes.

-or-

source does not support reading.

Applies to

.NET 10 and other versions
Product Versions
.NET 7, 8, 9, 10

HashData(ReadOnlySpan<Byte>, Span<Byte>)

Source:
SHA1.cs
Source:
SHA1.cs
Source:
SHA1.cs

Computes the hash of data using the SHA1 algorithm.

C#
public static int HashData(ReadOnlySpan<byte> source, Span<byte> destination);

Parameters

source
ReadOnlySpan<Byte>

The data to hash.

destination
Span<Byte>

The buffer to receive the hash value.

Returns

The total number of bytes written to destination.

Exceptions

The buffer in destination is too small to hold the calculated hash size. The SHA1 algorithm always produces a 160-bit hash, or 20 bytes.

Applies to

.NET 10 and other versions
Product Versions
.NET 5, 6, 7, 8, 9, 10