68 lines
2.1 KiB
C#
68 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
namespace bdAsegasa.db
|
|
{
|
|
public partial class ficheros
|
|
{
|
|
public string idFicheroEnc
|
|
{
|
|
get
|
|
{
|
|
string idStr = this.idFichero.ToString().PadLeft(8, '0');
|
|
using (SHA1 sha1 = SHA1.Create())
|
|
{
|
|
byte[] hash = sha1.ComputeHash(Encoding.ASCII.GetBytes("ASEGASa" + idStr));
|
|
string dc = hash[0].ToString("x2");
|
|
// Using tsUtilidades for encryption
|
|
return tsUtilidades.crypt.FEncS(idStr + dc, "1973122213","",0);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static int ObtieneidFichero(string idEncriptado)
|
|
{
|
|
try
|
|
{
|
|
string idcdc = tsUtilidades.crypt.FEncS(idEncriptado, "1973122213","",0);
|
|
if (idcdc.Length < 10) return 0;
|
|
string idr = idcdc.Substring(0, 8);
|
|
string dc = idcdc.Substring(8, 2);
|
|
|
|
using (SHA1 sha1 = SHA1.Create())
|
|
{
|
|
byte[] hash = sha1.ComputeHash(Encoding.ASCII.GetBytes("ASEGASa" + idr));
|
|
if (hash[0].ToString("x2") != dc) return 0;
|
|
return int.Parse(idr);
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
public class vr_ficheros
|
|
{
|
|
public int idFichero { get; set; }
|
|
public string NombreFichero { get; set; }
|
|
public DateTime Fecha { get; set; }
|
|
public string Descripcion { get; set; }
|
|
|
|
public static List<vr_ficheros> Obtiene_vr_ficheros(IQueryable<ficheros> iqFicheros)
|
|
{
|
|
return iqFicheros.Select(x => new vr_ficheros
|
|
{
|
|
idFichero = x.idFichero,
|
|
NombreFichero = x.NombreFichero,
|
|
Fecha = (DateTime)x.Fecha,
|
|
Descripcion = x.Descripcion
|
|
}).ToList();
|
|
}
|
|
}
|
|
}
|