72 lines
1.9 KiB
C#
72 lines
1.9 KiB
C#
using GPW.CORE.Data.DbModels;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
namespace GPW.CORE.Data
|
|
{
|
|
/// <summary>
|
|
/// Classe validazione valori
|
|
/// </summary>
|
|
public class DataValidator
|
|
{
|
|
#region Public Constructors
|
|
|
|
public DataValidator(DipendentiModel? currRigaDip)
|
|
{
|
|
rigaDip = currRigaDip;
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Restituisce HASH del codice impiego = payload utente
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string HashDip
|
|
{
|
|
get => calcHashDip;
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Private Fields
|
|
|
|
private DipendentiModel? rigaDip = null;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
/// <summary>
|
|
/// Calcola HASH del codice impiego = payload utente
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private string calcHashDip
|
|
{
|
|
get
|
|
{
|
|
string hash = "";
|
|
string buffData = "";
|
|
if (rigaDip != null)
|
|
{
|
|
buffData = $"{rigaDip.IdxDipendente}|{rigaDip.Cognome}.{rigaDip.Nome}|{rigaDip.Cf}|{rigaDip.DataAssunzione:yyyyMMdd}|{rigaDip.Email}|{rigaDip.Matricola}";
|
|
}
|
|
if (!string.IsNullOrEmpty(buffData))
|
|
{
|
|
// hashing!
|
|
using (var md5 = MD5.Create())
|
|
{
|
|
byte[] InputBytes = Encoding.UTF8.GetBytes(buffData);
|
|
var byteHash = md5.ComputeHash(InputBytes);
|
|
hash = BitConverter.ToString(byteHash).Replace("-", "").ToLowerInvariant();
|
|
}
|
|
}
|
|
return hash;
|
|
}
|
|
}
|
|
|
|
#endregion Private Properties
|
|
}
|
|
} |