Md5 + Sha1 in c#

This article has been written before more than 24months, information might old.

Aveam nevoie de o criptare sha1 aveam cain ( normal ) dar cain nu ma ajuta pentru ca cu toate ca iti calculeaza o groaza de hash-uri ti le pune pe toate capitalizate , iar de cele mai multe ori f1f501c2c23fea8dfb0fe1af25b879d1 nu este la fel cu F1F501C2C23FEA8DFB0FE1AF25B879D1 de asta aveam nevoie de un exe mic si rapid care sa cripteze md5 + sha1 fara sa capitalizeze toate caracterele asa ca am scris repede unul in c# ( din care am mai taiat din encriptari pentru ca multe din ele nu prea se folosesc )
O poza mai jos :

md5 calk

Binarul : aici

Nu cred ca intereseaza pe cineva codul sursa( avand in vedere ca oricine face asa ceva si gasesti pe net oricum ) dar ma rog mai jos este si el :

using System;
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.Security.Cryptography;

namespace hascalc
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

    public string md5enc(string originalPassword)
    {
        //Declarations
        Byte[] originalBytes;
        Byte[] encodedBytes;
        MD5 entxt;

        //Instantiate MD5CryptoServiceProvider, get bytes for original password and compute hash (encoded password)
        entxt = new MD5CryptoServiceProvider();
        originalBytes = ASCIIEncoding.Default.GetBytes(originalPassword);
        encodedBytes = entxt.ComputeHash(originalBytes);

        //Convert encoded bytes back to a 'readable' string
        string beaze = BitConverter.ToString(encodedBytes).ToLower();
        return beaze.Replace("-", "");
    }

    public string sha1enc(string originalPassword)
    {
        //Declarations
        Byte[] originalBytes;
        Byte[] encodedBytes;
        SHA1 entxt;

        //Instantiate MD5CryptoServiceProvider, get bytes for original password and compute hash (encoded password)
        entxt = new SHA1CryptoServiceProvider();
        originalBytes = ASCIIEncoding.Default.GetBytes(originalPassword);
        encodedBytes = entxt.ComputeHash(originalBytes);

        //Convert encoded bytes back to a 'readable' string
      string  beaze = BitConverter.ToString(encodedBytes).ToLower();
        return beaze.Replace("-","");
    }

    public string sha256enc(string originalPassword)
    {
        //Declarations
        Byte[] originalBytes;
        Byte[] encodedBytes;
        SHA256 entxt;

        //Instantiate MD5CryptoServiceProvider, get bytes for original password and compute hash (encoded password)
        entxt = new SHA256CryptoServiceProvider();
        originalBytes = ASCIIEncoding.Default.GetBytes(originalPassword);
        encodedBytes = entxt.ComputeHash(originalBytes);

        //Convert encoded bytes back to a 'readable' string
        string beaze = BitConverter.ToString(encodedBytes).ToLower();
        return beaze.Replace("-", "");
    }

    public string sha384enc(string originalPassword)
    {
        //Declarations
        Byte[] originalBytes;
        Byte[] encodedBytes;
        SHA384 entxt;

        //Instantiate MD5CryptoServiceProvider, get bytes for original password and compute hash (encoded password)
        entxt = new SHA384CryptoServiceProvider();
        originalBytes = ASCIIEncoding.Default.GetBytes(originalPassword);
        encodedBytes = entxt.ComputeHash(originalBytes);

        //Convert encoded bytes back to a 'readable' string
        string beaze = BitConverter.ToString(encodedBytes).ToLower();
        return beaze.Replace("-", "");
    }

    public string sha512enc(string originalPassword)
    {
        //Declarations
        Byte[] originalBytes;
        Byte[] encodedBytes;
        SHA512 entxt;

        //Instantiate MD5CryptoServiceProvider, get bytes for original password and compute hash (encoded password)
        entxt = new SHA512CryptoServiceProvider();
        originalBytes = ASCIIEncoding.Default.GetBytes(originalPassword);
        encodedBytes = entxt.ComputeHash(originalBytes);

        //Convert encoded bytes back to a 'readable' string
        string beaze = BitConverter.ToString(encodedBytes).ToLower();
        return beaze.Replace("-", "");
    }

        private void button1_Click(object sender, EventArgs e)
        {

            if (this.input.Text.ToString() == null || this.input.Text.ToString() == "")
            {
                // nimic
                MessageBox.Show("Input is empty !");
            }
            else
            {
                this.output.Text = "";
                string text = this.input.Text.ToString();
                this.output.Text += string.Concat("[md5] :  ", md5enc(text)) + Environment.NewLine + Environment.NewLine;
                this.output.Text += string.Concat("[sha1] :  ", sha1enc(text)) + Environment.NewLine + Environment.NewLine;
                //this.output.Text += string.Concat("[sha256] :  ", sha256enc(text)) + Environment.NewLine + Environment.NewLine;
                //this.output.Text += string.Concat("[sha384] :  ", sha384enc(text)) + Environment.NewLine + Environment.NewLine;
                //this.output.Text += string.Concat("[sha512] :  ", sha512enc(text)) + Environment.NewLine + Environment.NewLine;

            }

        }
    }
}
Share the joy

2 Comments

  1. Master februarie 9, 2009
  2. ceostoy februarie 7, 2009

Leave a Reply