21 lines
683 B
C#
21 lines
683 B
C#
using System.IO;
|
|
using StellaOps.Cryptography;
|
|
using StellaOps.TestKit;
|
|
using Xunit;
|
|
|
|
namespace StellaOps.Cryptography.Tests;
|
|
|
|
public sealed partial class DefaultCryptoHashTests
|
|
{
|
|
[Trait("Category", TestCategories.Unit)]
|
|
[Fact]
|
|
public async Task ComputeHash_Stream_MatchesBuffer_Async()
|
|
{
|
|
var hash = CryptoHashFactory.CreateDefault();
|
|
await using var stream = new MemoryStream(_sample);
|
|
var streamDigest = await hash.ComputeHashAsync(stream, HashAlgorithms.Sha256);
|
|
var bufferDigest = hash.ComputeHash(_sample, HashAlgorithms.Sha256);
|
|
Assert.Equal(Convert.ToHexString(bufferDigest), Convert.ToHexString(streamDigest));
|
|
}
|
|
}
|