Hash - MD5





using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Security.Cryptography;

namespace MD5_V._1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button3_Click(object sender, EventArgs e)
{
Application.Exit();
}

private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Text = "";
}

private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text !="")
{
HashAlgorithm codigo = new MD5CryptoServiceProvider();
// Byte[] textoOriginal = ASCIIEncoding.Default.GetBytes(textBox1.Text); //Usar ASCII o UTF8
Byte[] textoOriginal = UTF8Encoding.Default.GetBytes(textBox1.Text);
Byte[] valor = codigo.ComputeHash(textoOriginal);
textBox2.Text = BitConverter.ToString(valor).ToLower();
}
else
MessageBox.Show("Insertar el texto a codificar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}

}







No hay comentarios:

Publicar un comentario

Nota: solo los miembros de este blog pueden publicar comentarios.