Underc0de

Programación General => C# - VB.NET => Mensaje iniciado por: kraft en Marzo 11, 2013, 11:14:11 PM

Título: Convertir Cualquier Cadena De Texto A Md5
Publicado por: kraft en Marzo 11, 2013, 11:14:11 PM
Es tema pasado, pero quería probar esto de los foros  :P
en vb.net se agregan 2 textbox's y un button, y los que conozcan el tema ya entienden lo que digo
si alguno tiene dudas (que no creo) estaré dispuesto a hacer lo que pueda
bien, ahi está:
_____________________________________________________________________
Código (csharp) [Seleccionar]
Imports System.Text
Imports System.Security.Cryptography
Public Class Form2
   

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        CifradoMd5(TextBox1.Text)
    End Sub
    Private Sub CifradoMd5(ByVal TextoCifrar As String)
        Dim TextoCifrado As String
        TextoCifrado = ""
        Dim md5 As New MD5CryptoServiceProvider
        Dim bytValue() As Byte
        Dim bytHash() As Byte
        Dim i As Integer

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

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

        For i = 0 To bytHash.Length - 1
            TextoCifrado &= bytHash(i).ToString("x").PadLeft(2, "0")
        Next
        TextBox2.Text = TextoCifrado
        Form1.TextBox3.Text = TextoCifrado
    End Sub
End Class

_______________________________________________________________