mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 09:36:30 +00:00
22 lines
810 B
C#
22 lines
810 B
C#
using System.IO;
|
|
|
|
namespace Azaion.Common.Services;
|
|
|
|
public interface IResourceLoader
|
|
{
|
|
Task<MemoryStream> Load(string fileName, CancellationToken cancellationToken = default);
|
|
}
|
|
|
|
public class ResourceLoader(string email, string password, AzaionApiClient api, IHardwareService hardwareService) : IResourceLoader
|
|
{
|
|
public async Task<MemoryStream> Load(string fileName, CancellationToken cancellationToken = default)
|
|
{
|
|
var hardwareInfo = await hardwareService.GetHardware();
|
|
var encryptedStream = await api.GetResource(fileName, password, hardwareInfo);
|
|
|
|
var key = Security.MakeEncryptionKey(email, password, hardwareInfo.Hash);
|
|
var stream = new MemoryStream();
|
|
await encryptedStream.DecryptTo(stream, key, cancellationToken);
|
|
return stream;
|
|
}
|
|
} |