Iceshrimp.NET/Iceshrimp.Backend/Core/Helpers/DigestHelpers.cs
Laura Hausmann c07bb35548
[backend/drive] Refactor ImageProcessor into a modular system
This commit lays the groundwork for a user-configurable image processing pipeline. It has exactly the same behavior as the old ImageProcessor, just modular & compartmentalized. It also adds support for AVIF & JXL encoding, though no code paths call it just yet.
2024-08-12 03:21:03 +02:00

24 lines
No EOL
620 B
C#

using System.Security.Cryptography;
using System.Text;
namespace Iceshrimp.Backend.Core.Helpers;
public static class DigestHelpers
{
public static async Task<string> Sha256DigestAsync(string input)
{
var bytes = Encoding.UTF8.GetBytes(input);
return await Sha256DigestAsync(new MemoryStream(bytes));
}
public static async Task<string> Sha256DigestAsync(Stream input)
{
var data = await SHA256.HashDataAsync(input);
return Convert.ToHexString(data).ToLowerInvariant();
}
public static async Task<string> Sha256DigestAsync(byte[] input)
{
return await Sha256DigestAsync(new MemoryStream(input));
}
}