elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Security Series.XSS. [Cross Site Scripting]


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  [AYUDA] VB.NET BUSCAR EN UN DIRECTORIO Y COMPARAR EL CHEKSUM MD5
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [AYUDA] VB.NET BUSCAR EN UN DIRECTORIO Y COMPARAR EL CHEKSUM MD5  (Leído 3,532 veces)
DragonsWP

Desconectado Desconectado

Mensajes: 23


Ver Perfil
[AYUDA] VB.NET BUSCAR EN UN DIRECTORIO Y COMPARAR EL CHEKSUM MD5
« en: 20 Julio 2013, 00:23 am »

Buenas tardes, necesito ayuda necesito buscar en un directorio (Cantidad de Archivos en carpeta 500) y comparar el cheksum md5 de un archivo, con el que le indique.
estoy usando vb.net 2008 aver si alguien me puede ayudar con este asunto.

Saludos.

Atte.

Brayan Quispe


En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.818



Ver Perfil
Re: [AYUDA] VB.NET BUSCAR EN UN DIRECTORIO Y COMPARAR EL CHEKSUM MD5
« Respuesta #1 en: 20 Julio 2013, 02:17 am »

Código
  1. #Region " Get Files "
  2.  
  3.    ' [ Get Files Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    '
  9.    ' For Each file In Get_Files("C:\Windows", False) : MsgBox(file.Name) : Next
  10.    '
  11.    ' For Each file In Get_Files("C:\Windows", True, "dll")   : MsgBox(file.Name) : Next
  12.    ' For Each file In Get_Files("C:\Windows", True, ".dll")  : MsgBox(file.Name) : Next
  13.    ' For Each file In Get_Files("C:\Windows", True, "*.dll") : MsgBox(file.Name) : Next
  14.    '
  15.    ' For Each file In Get_Files("C:\Windows", False, {"dll", "ini"})     : MsgBox(file.Name) : Next
  16.    ' For Each file In Get_Files("C:\Windows", False, {".dll", ".ini"})   : MsgBox(file.Name) : Next
  17.    ' For Each file In Get_Files("C:\Windows", False, {"*.dll", "*.ini"}) : MsgBox(file.Name) : Next
  18.  
  19.    ' Get Files {directory} {recursive}
  20.    Private Function Get_Files(ByVal directory As String, ByVal recursive As Boolean) As List(Of IO.FileInfo)
  21.        Dim searchOpt As IO.SearchOption = If(recursive, IO.SearchOption.AllDirectories, IO.SearchOption.TopDirectoryOnly)
  22.        Return IO.Directory.GetFiles(directory, "*", searchOpt).Select(Function(p) New IO.FileInfo(p)).ToList
  23.    End Function
  24.  
  25.    ' Get Files {directory} {recursive} {ext}
  26.    Private Function Get_Files(ByVal directory As String, ByVal recursive As Boolean, ext As String) As List(Of IO.FileInfo)
  27.  
  28.        If ext.StartsWith("*") Then
  29.            ext = ext.Substring(1, ext.Length - 1)
  30.        ElseIf Not ext = "*" AndAlso Not ext.StartsWith(".") Then
  31.            ext = ("." & ext)
  32.        ElseIf ext = "*" Then
  33.            ext = Nothing
  34.        End If
  35.  
  36.        Dim searchOpt As IO.SearchOption = If(recursive, IO.SearchOption.AllDirectories, IO.SearchOption.TopDirectoryOnly)
  37.        Return IO.Directory.GetFiles(directory, "*" & ext, searchOpt).Select(Function(p) New IO.FileInfo(p)).ToList
  38.  
  39.    End Function
  40.  
  41.    ' Get Files {directory} {recursive} {exts()}
  42.    Private Function Get_Files(ByVal directory As String, ByVal recursive As Boolean, ParamArray exts() As String) As List(Of IO.FileInfo)
  43.  
  44.        Dim FileExts(exts.Count) As String
  45.        Dim ExtCount As Int32 = 0
  46.  
  47.        For Each ext In exts
  48.            If ext.StartsWith("*") Then
  49.                FileExts(ExtCount) = ext.Substring(1, ext.Length - 1)
  50.            ElseIf Not ext = "*" AndAlso Not ext.StartsWith(".") Then
  51.                FileExts(ExtCount) = ("." & ext)
  52.            ElseIf Not ext = "*" AndAlso ext.StartsWith(".") Then
  53.                FileExts(ExtCount) = ext
  54.            ElseIf ext = "*" Then
  55.                FileExts(ExtCount) = Nothing
  56.            End If
  57.            ExtCount += 1
  58.        Next
  59.  
  60.        Dim searchOpt As IO.SearchOption = If(recursive, IO.SearchOption.AllDirectories, IO.SearchOption.TopDirectoryOnly)
  61.        Dim filenameExtComparer As New FilenameExtensionComparer
  62.        Return IO.Directory.GetFiles(directory, "*", searchOpt).Where(Function(o) FileExts.Contains(IO.Path.GetExtension(o), filenameExtComparer)).Select(Function(p) New IO.FileInfo(p)).ToList
  63.  
  64.    End Function
  65.  
  66.    ' FilenameExtensionComparer (Ignore Case) needed for "Get Files {directory} {recursive} {exts()}" overload.
  67.    Public Class FilenameExtensionComparer : Implements IEqualityComparer(Of String)
  68.  
  69.        Public Function Equals1(s As String, t As String) As Boolean Implements IEqualityComparer(Of String).Equals
  70.            Return String.Compare(s, t, StringComparison.OrdinalIgnoreCase) = 0
  71.        End Function
  72.  
  73.        Public Function GetHashCode1(s As String) As Integer Implements IEqualityComparer(Of String).GetHashCode
  74.            Return s.GetHashCode()
  75.        End Function
  76.  
  77.    End Class
  78.  
  79. #End Region


Código
  1.        #Region " Get MD5 Of File Function "
  2.  
  3.          ' [ Get MD5 Of File Function ]
  4.          '
  5.          ' Examples :
  6.          '
  7.          ' MsgBox(Get_MD5_Of_File("C:\Test.txt"))
  8.  
  9.          Private Function Get_MD5_Of_File(ByVal File As String) As String
  10.              Using MD5_Reader As New System.IO.FileStream(File, IO.FileMode.Open, IO.FileAccess.Read)
  11.                  Using MD5 As New System.Security.Cryptography.MD5CryptoServiceProvider
  12.                      Dim MD5_Byte() As Byte = MD5.ComputeHash(MD5_Reader)
  13.                      Dim MD5_Hex As New System.Text.StringBuilder(MD5.ComputeHash(MD5_Reader).Length * 2)
  14.                      For Number As Integer = 0 To MD5_Byte.Length - 1
  15.                          Application.DoEvents()
  16.                          MD5_Hex.Append(MD5_Byte(Number).ToString("X2"))
  17.                      Next
  18.                      Return MD5_Hex.ToString().ToLower
  19.                  End Using
  20.              End Using
  21.          End Function
  22.  
  23.       #End Region

...Aquí más -> Librería de Snippets !! (Posteen aquí sus snippets)


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
AYUDA URGENTE!!! >>> [Abrir .doc y Comparar]
Programación Visual Basic
Garet-deRioth 0 1,098 Último mensaje 25 Octubre 2007, 07:16 am
por Garet-deRioth
Comparar fechas. Ayuda! C++ « 1 2 »
Programación C/C++
Wazzp 16 18,208 Último mensaje 25 Septiembre 2010, 19:33 pm
por Wazzp
Ayuda para comparar una cadena con el nombre de una variable int
Programación C/C++
dato000 6 5,401 Último mensaje 7 Marzo 2011, 11:54 am
por dato000
Microsoft: comparar IE9 y Firefox 4 es como comparar “manzanas y naranjas” « 1 2 »
Noticias
wolfbcn 15 7,258 Último mensaje 27 Marzo 2011, 04:35 am
por Foxy Rider
COMPARAR LOS DOS ARREGLOS!! AYUDA
Programación C/C++
JoseCheO 0 7,133 Último mensaje 10 Noviembre 2011, 03:29 am
por JoseCheO
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines