using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
using System.Security.Cryptography;
using System.Text;
namespace EnvelopeGenerator.Application.Dto.Receiver;
///
///
///
[ApiExplorerSettings(IgnoreApi = true)]
public record ReceiverCreateDto
{
///
///
///
public ReceiverCreateDto()
{
_sha256HexOfMail = new(() =>
{
var bytes_arr = Encoding.UTF8.GetBytes(EmailAddress!.ToUpper());
var hash_arr = SHA256.HashData(bytes_arr);
var hexa_str = BitConverter.ToString(hash_arr);
return hexa_str.Replace("-", string.Empty);
});
}
///
///
///
[EmailAddress]
public required string EmailAddress { get; init; }
///
///
///
public string? TotpSecretkey { get; init; }
///
/// var bytes_arr = Encoding.UTF8.GetBytes(EmailAddress.ToUpper());
/// var hash_arr = SHA256.HashData(bytes_arr);
/// var hexa_str = BitConverter.ToString(hash_arr);
/// return hexa_str.Replace("-", string.Empty);
///
public string Signature => _sha256HexOfMail.Value;
private readonly Lazy _sha256HexOfMail;
///
/// Default value is DateTime.Now
///
public DateTime AddedWhen { get; } = DateTime.Now;
};