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