using GB5Shared.DTO.Framework.ResponseStandard;
using Microsoft.AspNetCore.Mvc;
using FrameworkBLL.Encryption;
using FrameworkDAL.DTO.Encryption;
using static GB5Shared.GB5Constant.Constant;
namespace FrameworkSL.Controllers.Encryption
{
///
/// Provides EncryptionController.
///
[ApiController]
[Route("[controller]")]
public class EncryptionController : ControllerBase
{
private readonly IEncryptionBLL _IEncryptionBLL;
///
/// EncryptionController
///
///
public EncryptionController(IEncryptionBLL IEncryptionBLL)
{
_IEncryptionBLL = IEncryptionBLL;
}
///
/// Encrypts data using the supplied PublicKey.
///
///
///
///
[HttpGet("EncryptData")]
public async Task> EncryptData(string data, string PublicKey)
{
try
{
string token = _IEncryptionBLL.Encrypt(data, PublicKey);
return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(
new EncryptResponseDTO { Token = token }, CacheKeyLevel.NOT_REQUIRED, null!);
}
catch (Exception ex)
{
return await GB5Shared.ResponseStandard.Response.CreateExceptionError(
ex, CacheKeyLevel.NOT_REQUIRED, null!, ex.Message, 500
);
}
}
}
}