Added shared projects
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
namespace LiteCharms.Features.Utilities.Commands.Handlers;
|
||||
|
||||
public class ComputeHashCommandHandler : IRequestHandler<ComputeHashCommand, Result<string>>
|
||||
{
|
||||
public async ValueTask<Result<string>> Handle(ComputeHashCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var bytes = SHA256.HashData(Encoding.UTF8.GetBytes(request.Input!));
|
||||
|
||||
return Result.Ok(Convert.ToHexString(bytes));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Result.Fail<string>(new Error(ex.Message).CausedBy(ex));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user