Oppure

Loading
24/03/08 12:58
Dark_Limit
Ciao a tutti!!
Dovrei trovare l' MD5 di un file usando codice in vb.net sapete come si fa? Credo si importi la classe Criptography e Text ma non ho ben capito come trovare l'hash md5 del file esaminato..Grazie a coloro che risponderanno! :k:
aaa
25/03/08 9:34
Il Totem
totem.altervista.org/guida/versione2/…
Riporto direttamente il codice:
Imports System.Security
Imports System.Security.Cryptography
Imports System.Text.UTF8Encoding
Module Module2
    'Questa semplice funzione genera un hash MD5
    Public Function GetMd5(ByVal Text As String) As Byte()
        Dim Input As Byte() = UTF8.GetBytes(Text)
        Dim Output As Byte()

        'MD5.Create() crea un nuovo provider crittografico per l'hash Md5
        Output = MD5.Create().ComputeHash(Input, 0, Input.Length)
        Return Output
    End Function

    Sub Main()
        Dim Input As String

        Console.WriteLine("Inserire un testo qualsiasi:")
        Input = Console.ReadLine

        Console.WriteLine()
        Console.WriteLine("Il suo hash è:")
        Console.WriteLine(ToHex(GetMd5(Input)))
        Console.ReadKey()
    End Sub
End Module 

ToHex è una funzione che converte un'array di bytes in una stringa nella quale sono presenti i corrispettivi codici esadecimale, così da poterla stampare. La sua definizione è nel sorgente precedente alla pagina indicata.
aaa