using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace StellaOps.Cryptography;
///
/// Interface for cryptographic hashing operations with compliance profile support.
///
public interface ICryptoHash
{
#region Algorithm-based methods (backward compatible)
///
/// Computes a hash using the specified or default algorithm.
///
/// The data to hash.
/// Optional algorithm identifier. If null, uses the default algorithm.
/// The hash bytes.
byte[] ComputeHash(ReadOnlySpan data, string? algorithmId = null);
///
/// Computes a hash and returns it as a lowercase hex string.
///
string ComputeHashHex(ReadOnlySpan data, string? algorithmId = null);
///
/// Computes a hash and returns it as a Base64 string.
///
string ComputeHashBase64(ReadOnlySpan data, string? algorithmId = null);
///
/// Computes a hash from a stream asynchronously.
///
ValueTask ComputeHashAsync(Stream stream, string? algorithmId = null, CancellationToken cancellationToken = default);
///
/// Computes a hash from a stream and returns it as a lowercase hex string.
///
ValueTask ComputeHashHexAsync(Stream stream, string? algorithmId = null, CancellationToken cancellationToken = default);
#endregion
#region Purpose-based methods (preferred for compliance)
///
/// Computes a hash for the specified purpose using the active compliance profile's algorithm.
///
/// The data to hash.
/// The hash purpose from .
/// The hash bytes.
byte[] ComputeHashForPurpose(ReadOnlySpan data, string purpose);
///
/// Computes a hash for the specified purpose and returns it as a lowercase hex string.
///
/// The data to hash.
/// The hash purpose from .
/// The hash as a lowercase hex string.
string ComputeHashHexForPurpose(ReadOnlySpan data, string purpose);
///
/// Computes a hash for the specified purpose and returns it as a Base64 string.
///
/// The data to hash.
/// The hash purpose from .
/// The hash as a Base64 string.
string ComputeHashBase64ForPurpose(ReadOnlySpan data, string purpose);
///
/// Computes a hash for the specified purpose from a stream asynchronously.
///
/// The stream to hash.
/// The hash purpose from .
/// Cancellation token.
/// The hash bytes.
ValueTask ComputeHashForPurposeAsync(Stream stream, string purpose, CancellationToken cancellationToken = default);
///
/// Computes a hash for the specified purpose from a stream and returns it as a lowercase hex string.
///
/// The stream to hash.
/// The hash purpose from .
/// Cancellation token.
/// The hash as a lowercase hex string.
ValueTask ComputeHashHexForPurposeAsync(Stream stream, string purpose, CancellationToken cancellationToken = default);
#endregion
#region Metadata methods
///
/// Gets the algorithm that will be used for the specified purpose based on the active compliance profile.
///
/// The hash purpose from .
/// The algorithm identifier.
string GetAlgorithmForPurpose(string purpose);
///
/// Gets the hash prefix for the specified purpose (e.g., "blake3:", "sha256:", "gost3411:").
///
/// The hash purpose from .
/// The hash prefix string.
string GetHashPrefix(string purpose);
///
/// Computes a hash for the specified purpose and returns it with the appropriate prefix.
///
/// The data to hash.
/// The hash purpose from .
/// The prefixed hash string (e.g., "blake3:abc123...").
string ComputePrefixedHashForPurpose(ReadOnlySpan data, string purpose);
#endregion
}