Class Ripemd160
- Namespace
- CryptoHives.Foundation.Security.Cryptography.Hash
- Assembly
- CryptoHives.Foundation.Security.Cryptography.dll
Computes the RIPEMD-160 hash for the input data.
public sealed class Ripemd160 : HashAlgorithm, ICryptoTransform, IDisposable, IResettable
- Inheritance
-
Ripemd160
- Implements
- Inherited Members
Remarks
RIPEMD-160 is a 160-bit cryptographic hash function designed by Hans Dobbertin, Antoon Bosselaers, and Bart Preneel. It is widely used in cryptocurrency systems, particularly Bitcoin for address generation (in combination with SHA-256).
This is a fully managed implementation that does not rely on OS or hardware cryptographic APIs, ensuring deterministic behavior across all platforms.
Note: While RIPEMD-160 is still considered secure for its design goals, SHA-256 or SHA-3 are recommended for new applications requiring 128+ bit security.
Constructors
Ripemd160()
Initializes a new instance of the Ripemd160 class.
public Ripemd160()
Fields
BlockSizeBytes
The block size in bytes.
public const int BlockSizeBytes = 64
Field Value
HashSizeBits
The hash size in bits.
public const int HashSizeBits = 160
Field Value
HashSizeBytes
The hash size in bytes.
public const int HashSizeBytes = 20
Field Value
Properties
AlgorithmName
Gets the name of the hash algorithm.
public override string AlgorithmName { get; }
Property Value
BlockSize
Gets the block size in bytes used by the hash algorithm.
public override int BlockSize { get; }
Property Value
Methods
Create()
Creates a new instance of the Ripemd160 class.
public static Ripemd160 Create()
Returns
- Ripemd160
A new RIPEMD-160 hash algorithm instance.
Dispose(bool)
Releases the unmanaged resources used by the HashAlgorithm and optionally releases the managed resources.
protected override void Dispose(bool disposing)
Parameters
disposingbooltrue to release both managed and unmanaged resources; false to release only unmanaged resources.
HashCore(ReadOnlySpan<byte>)
When overridden in a derived class, routes data written to the object into the hash algorithm for computing the hash.
protected override void HashCore(ReadOnlySpan<byte> source)
Parameters
sourceReadOnlySpan<byte>The input to compute the hash code for.
Exceptions
- ObjectDisposedException
Thrown when the instance has been disposed.
HashData(in ReadOnlySequence<byte>)
Computes the RIPEMD-160 hash of source and returns it as a new byte array.
public static byte[] HashData(in ReadOnlySequence<byte> source)
Parameters
sourceReadOnlySequence<byte>The (possibly multi-segment) input sequence to hash.
Returns
- byte[]
A new byte array containing the RIPEMD-160 hash.
HashData(ReadOnlySpan<byte>)
Computes the RIPEMD-160 hash of source and returns it as a new byte array.
public static byte[] HashData(ReadOnlySpan<byte> source)
Parameters
sourceReadOnlySpan<byte>The input data to hash.
Returns
- byte[]
A new byte array containing the RIPEMD-160 hash.
Initialize()
Initializes an implementation of the HashAlgorithm class.
public override void Initialize()
Exceptions
- ObjectDisposedException
Thrown when the instance has been disposed.
TryHashData(in ReadOnlySequence<byte>, Span<byte>, out int)
Computes the RIPEMD-160 hash of source and writes it into destination.
public static bool TryHashData(in ReadOnlySequence<byte> source, Span<byte> destination, out int bytesWritten)
Parameters
sourceReadOnlySequence<byte>The (possibly multi-segment) input sequence to hash.
destinationSpan<byte>The buffer to receive the hash value. Must be at least HashSizeBytes bytes.
bytesWrittenintWhen this method returns, the number of bytes written into
destination.
Returns
TryHashData(ReadOnlySpan<byte>, Span<byte>, out int)
Computes the RIPEMD-160 hash of source and writes it into destination.
public static bool TryHashData(ReadOnlySpan<byte> source, Span<byte> destination, out int bytesWritten)
Parameters
sourceReadOnlySpan<byte>The input data to hash.
destinationSpan<byte>The buffer to receive the hash value. Must be at least HashSizeBytes bytes.
bytesWrittenintWhen this method returns, the number of bytes written into
destination.
Returns
TryHashFinal(Span<byte>, out int)
When overridden in a derived class, finalizes the hash computation and writes the result into the provided buffer.
protected override bool TryHashFinal(Span<byte> destination, out int bytesWritten)
Parameters
destinationSpan<byte>The target buffer to write the hash to.
bytesWrittenintThe number of bytes written into the buffer.