Programación

Visual Basic .Net

Función para obtener MD5

Imports System.Security.Cryptography

Public Class StringsUtilities
    Public Shared Function getMD5(ByVal StrPass As String) As String

        Dim PasConMd5 As String = ""
        Dim md5 As New MD5CryptoServiceProvider
        Dim bytValue() As Byte
        Dim bytHash() As Byte
        Dim i As Integer

        bytValue = System.Text.Encoding.UTF8.GetBytes(StrPass)

        bytHash = md5.ComputeHash(bytValue)
        md5.Clear()

        For i = 0 To bytHash.Length - 1
            PasConMd5 &= bytHash(i).ToString("x").PadLeft(2, "0")
        Next

        getMD5 = PasConMd5

        End Function
    End Class