Files
Asegasa.NET/guia/Extensiones/ficheros.vb
2026-04-28 11:52:16 +02:00

43 lines
1.9 KiB
VB.net

Partial Public Class ficheros
Public ReadOnly Property idFicheroEnc As String
Get
Dim oCodigo As New System.Text.ASCIIEncoding
Dim byHash() As Byte, shaTmp As New System.Security.Cryptography.SHA1CryptoServiceProvider
byHash = shaTmp.ComputeHash(oCodigo.GetBytes("ASEGASa" & Me.idFichero.ToString.PadLeft(8, "0")))
Return tsl5.crypt.FEncS(Me.idFichero.ToString.PadLeft(8, "0") & byHash(0).ToString("x2"), "[AN]", "[AN]", 1973122213)
End Get
End Property
Public Shared Function ObtieneidFichero(idEncriptado As String) As Integer
Try
Dim oCodigo As New System.Text.ASCIIEncoding
Dim idcdc = tsl5.crypt.FEncS(idEncriptado, "[AN]", "[AN]", -1973122213)
Dim idr = idcdc.Substring(0, 8)
Dim dc = idcdc.Substring(8, 2)
Dim byHash() As Byte, shaTmp As New System.Security.Cryptography.SHA1CryptoServiceProvider
byHash = shaTmp.ComputeHash(oCodigo.GetBytes("ASEGASa" & idr))
If byHash(0).ToString("x2") <> dc Then
Return 0
Else
Return idr
End If
Catch ex As Exception
Return 0
End Try
End Function
End Class
Partial Public Class vr_ficheros
Public Property idFichero As Integer
Public Property NombreFichero As String
Public Property Fecha As DateTime
Public Property Descripcion As String
Public Shared Function Obtiene_vr_ficheros(iqFicheros As IQueryable(Of ficheros)) As List(Of vr_ficheros)
Return iqFicheros.Select(Function(x) New vr_ficheros With {
.Descripcion = x.Descripcion,
.Fecha = x.Fecha,
.idFichero = x.idFichero,
.NombreFichero = x.NombreFichero}).ToList
End Function
End Class