Table of Contents

Class SHA512_224

Namespace
CryptoHives.Foundation.Security.Cryptography.Hash
Assembly
CryptoHives.Foundation.Security.Cryptography.dll

Computes the SHA-512/224 hash for the input data.

public sealed class SHA512_224 : Sha2HashAlgorithm<ulong>, ICryptoTransform, IDisposable, IResettable
Inheritance
SHA512_224
Implements
Inherited Members

Remarks

This is a fully managed implementation of SHA-512/224 that does not rely on OS or hardware cryptographic APIs, ensuring deterministic behavior across all platforms and runtimes.

SHA-512/224 uses the same compression function as SHA-512 but with different initial values (generated per FIPS 180-4) and a truncated 224-bit (28-byte) output.

Constructors

SHA512_224()

Initializes a new instance of the SHA512_224 class.

public SHA512_224()

Fields

HashSizeBits

The hash size in bits.

public const int HashSizeBits = 224

Field Value

int

HashSizeBytes

The hash size in bytes.

public const int HashSizeBytes = 28

Field Value

int

Properties

AlgorithmName

Gets the name of the hash algorithm.

public override string AlgorithmName { get; }

Property Value

string

BlockSize

Gets the block size in bytes used by the hash algorithm.

public override int BlockSize { get; }

Property Value

int

BlockSizeBytes

Gets the block size in bytes for this algorithm.

protected override int BlockSizeBytes { get; }

Property Value

int

OutputSizeBytes

Gets the hash output size in bytes.

protected override int OutputSizeBytes { get; }

Property Value

int

Methods

Create()

Creates a new instance of the SHA512_224 class.

public static SHA512_224 Create()

Returns

SHA512_224

A new SHA-512/224 hash algorithm instance.

HashData(in ReadOnlySequence<byte>)

Computes the SHA-512/224 hash of source and returns it as a new byte array.

public static byte[] HashData(in ReadOnlySequence<byte> source)

Parameters

source ReadOnlySequence<byte>

The (possibly multi-segment) input sequence to hash.

Returns

byte[]

A new byte array containing the SHA-512/224 hash.

HashData(ReadOnlySpan<byte>)

Computes the SHA-512/224 hash of source and returns it as a new byte array.

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

Parameters

source ReadOnlySpan<byte>

The input data to hash.

Returns

byte[]

A new byte array containing the SHA-512/224 hash.

InitializeState()

Initializes the hash state with algorithm-specific initial values.

protected override void InitializeState()

OutputHash(Span<byte>, ulong[])

Writes the final hash output from the state to the destination.

protected override void OutputHash(Span<byte> destination, ulong[] state)

Parameters

destination Span<byte>

The destination span for the hash output.

state ulong[]

The state array containing the hash values.

PadAndFinalize(Span<byte>, int, long, Span<ulong>)

Pads and finalizes the hash computation.

protected override void PadAndFinalize(Span<byte> buffer, int bufferLength, long bytesProcessed, Span<ulong> state)

Parameters

buffer Span<byte>

The buffer containing remaining unprocessed bytes.

bufferLength int

The number of valid bytes in the buffer.

bytesProcessed long

Total bytes processed before this finalization.

state Span<ulong>

The state array to update.

ProcessBlock(ReadOnlySpan<byte>, Span<ulong>)

Processes a single block, updating the state.

protected override void ProcessBlock(ReadOnlySpan<byte> block, Span<ulong> state)

Parameters

block ReadOnlySpan<byte>

The block data to process.

state Span<ulong>

The state array to update.

TryHashData(in ReadOnlySequence<byte>, Span<byte>, out int)

Computes the SHA-512/224 hash of source and writes it into destination.

public static bool TryHashData(in ReadOnlySequence<byte> source, Span<byte> destination, out int bytesWritten)

Parameters

source ReadOnlySequence<byte>

The (possibly multi-segment) input sequence to hash.

destination Span<byte>

The buffer to receive the hash value. Must be at least HashSizeBytes bytes.

bytesWritten int

When this method returns, the number of bytes written into destination.

Returns

bool

true if destination was large enough; otherwise, false.

TryHashData(ReadOnlySpan<byte>, Span<byte>, out int)

Computes the SHA-512/224 hash of source and writes it into destination.

public static bool TryHashData(ReadOnlySpan<byte> source, Span<byte> destination, out int bytesWritten)

Parameters

source ReadOnlySpan<byte>

The input data to hash.

destination Span<byte>

The buffer to receive the hash value. Must be at least HashSizeBytes bytes.

bytesWritten int

When this method returns, the number of bytes written into destination.

Returns

bool

true if destination was large enough; otherwise, false.