using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Security.Cryptography;
using System.Collections;
namespace Proyecto_Hash__Visual_
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text != "")
{
HashAlgorithm cod = new SHA1CryptoServiceProvider();
byte[] texto = Encoding.UTF8.GetBytes(textBox1.Text);
byte[] valor = cod.ComputeHash(texto);
cod.Clear();
textBox2.Text = Convert.ToBase64String(valor);
textBox3.Text = BitConverter.ToString(valor);
string suma;
foreach (byte b in valor)
{
suma = Convert.ToString(b);
textBox4.Text += suma + " ";
}
FileStream fs1 = new FileStream("original.arp", FileMode.Create, FileAccess.Write);
BinaryWriter sw = new BinaryWriter(fs1);
sw.Write(Encoding.ASCII.GetString(texto));
sw.Flush();
sw.Close();
fs1.Close();
fs1 = new FileStream("cifrado.arp", FileMode.Create, FileAccess.Write);
BinaryWriter bw = new BinaryWriter(fs1);
bw.Write(Convert.ToBase64String(valor));
bw.Close();
}
else
MessageBox.Show("Inserta la palabra o texto a codificar","Error");
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
}
}
}
No hay comentarios:
Publicar un comentario